LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "runtime.h" | 5 #include "runtime.h" |
6 #include "hashmap.h" | 6 #include "hashmap.h" |
7 #include "type.h" | 7 #include "type.h" |
8 | 8 |
9 /* Hmap flag values */ | 9 /* Hmap flag values */ |
10 #define IndirectVal (1<<0) /* storing pointers to values */ | 10 #define IndirectVal (1<<0) /* storing pointers to values */ |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 hash_hash_t ins_e_hash; | 409 hash_hash_t ins_e_hash; |
410 void *key; | 410 void *key; |
411 while (ins_e != end_e && ((e_hash = ins_e->hash) ^ hash)
< HASH_SUBHASH) { | 411 while (ins_e != end_e && ((e_hash = ins_e->hash) ^ hash)
< HASH_SUBHASH) { |
412 key = ins_e->data; | 412 key = ins_e->data; |
413 if (h->flag & IndirectKey) | 413 if (h->flag & IndirectKey) |
414 key = *(void**)key; | 414 key = *(void**)key; |
415 if (HASH_DATA_EQ (eq, t, h, data, key)) { /*
a match */ | 415 if (HASH_DATA_EQ (eq, t, h, data, key)) { /*
a match */ |
416 *pres = ins_e->data; | 416 *pres = ins_e->data; |
417 return (1); | 417 return (1); |
418 } | 418 } |
419 » » » » assert (e_hash != hash || (flags & HASH_REHASH)
== 0); | 419 » » » » if (e_hash == hash) {» /* adjust hash if it
collides */ |
420 » » » » hash += (e_hash == hash);» /* adjust has
h if it collides */ | 420 » » » » » assert ((flags & HASH_REHASH) == 0); |
| 421 » » » » » hash++; |
| 422 » » » » » if ((hash & HASH_MASK) == HASH_SUBHASH) |
| 423 » » » » » » runtime·throw("runtime: map hash
collision overflow"); |
| 424 » » » » } |
421 ins_e = HASH_OFFSET (ins_e, elemsize); | 425 ins_e = HASH_OFFSET (ins_e, elemsize); |
422 ins_i++; | 426 ins_i++; |
423 if (e_hash <= hash) { /* set e to inser
tion point */ | 427 if (e_hash <= hash) { /* set e to inser
tion point */ |
424 e = ins_e; | 428 e = ins_e; |
425 i = ins_i; | 429 i = ins_i; |
426 } | 430 } |
427 } | 431 } |
428 /* set ins_e to the insertion point for the new element
*/ | 432 /* set ins_e to the insertion point for the new element
*/ |
429 ins_e = e; | 433 ins_e = e; |
430 ins_i = i; | 434 ins_i = i; |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 t->elem->alg->copy(t->elem->size, av, hash_valptr(h, res)); | 1186 t->elem->alg->copy(t->elem->size, av, hash_valptr(h, res)); |
1183 | 1187 |
1184 if(debug) { | 1188 if(debug) { |
1185 runtime·prints("mapiter2: iter="); | 1189 runtime·prints("mapiter2: iter="); |
1186 runtime·printpointer(it); | 1190 runtime·printpointer(it); |
1187 runtime·prints("; map="); | 1191 runtime·prints("; map="); |
1188 runtime·printpointer(h); | 1192 runtime·printpointer(h); |
1189 runtime·prints("\n"); | 1193 runtime·prints("\n"); |
1190 } | 1194 } |
1191 } | 1195 } |
LEFT | RIGHT |