1
0
mirror of https://github.com/golang/go synced 2024-11-17 07:24:53 -07:00

allow pointers as keys in maps, treating them the same as ints - ptr eq not value equality

R=ken,gri
OCL=13879
CL=13879
This commit is contained in:
Rob Pike 2008-08-05 11:14:35 -07:00
parent 033682deec
commit 5adbacb8e7
2 changed files with 5 additions and 4 deletions

View File

@ -40,7 +40,7 @@ sys·newmap(uint32 keysize, uint32 valsize,
{
Hmap *m;
if(keyalg >= 2 ||
if(keyalg >= 3 ||
valalg >= 3) {
prints("0<=");
sys·printint(keyalg);

View File

@ -777,7 +777,8 @@ pointercopy(uint32 s, void **a, void **b)
Alg
algarray[3] =
{
{ &memhash, &memequal, &memprint, &memcopy },
{ &stringhash, &stringequal, &stringprint, &stringcopy },
{ &pointerhash, &pointerequal, &pointerprint, &pointercopy },
{ &memhash, &memequal, &memprint, &memcopy }, // 0
{ &stringhash, &stringequal, &stringprint, &stringcopy }, // 1
// { &pointerhash, &pointerequal, &pointerprint, &pointercopy }, // 2
{ &memhash, &memequal, &memprint, &memcopy }, // 2 - treat pointers as ints
};