From e781303e271cd2c062d7e834927210ad529e4d7d Mon Sep 17 00:00:00 2001 From: Ken Thompson Date: Tue, 23 Mar 2010 13:00:02 -0700 Subject: [PATCH] maps access to a missing key will return the "zero" value R=rsc CC=golang-dev https://golang.org/cl/700041 --- src/pkg/runtime/hashmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pkg/runtime/hashmap.c b/src/pkg/runtime/hashmap.c index 281601fbc76..ccb5cfdb56d 100644 --- a/src/pkg/runtime/hashmap.c +++ b/src/pkg/runtime/hashmap.c @@ -769,8 +769,10 @@ void av = (byte*)&h + h->vo1; mapaccess(h, ak, av, &pres); - if(!pres) - throw("runtime.mapaccess1: key not in map"); + +// new spec -- all elements have "zero" value +// if(!pres) +// throw("runtime.mapaccess1: key not in map"); if(debug) { prints("runtime.mapaccess1: map=");