1 /* go-type-string.c -- hash and equality string functions.
3 Copyright 2009 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
12 /* A string hash function for a map. */
15 __go_type_hash_string (const void *vkey,
16 uintptr_t key_size __attribute__ ((unused)))
19 const struct __go_string *key;
22 const unsigned char *p;
25 key = (const struct __go_string *) vkey;
27 for (i = 0, p = key->__data; i < len; i++, p++)
32 /* A string equality function for a map. */
35 __go_type_equal_string (const void *vk1, const void *vk2,
36 uintptr_t key_size __attribute__ ((unused)))
38 const struct __go_string *k1;
39 const struct __go_string *k2;
41 k1 = (const struct __go_string *) vk1;
42 k2 = (const struct __go_string *) vk2;
43 return (k1->__length == k2->__length
44 && __builtin_memcmp (k1->__data, k2->__data, k1->__length) == 0);