[svn:parrot] r48850 - branches/hash_inlined_func/src
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Wed Sep 8 02:27:04 UTC 2010
Author: chromatic
Date: Wed Sep 8 02:27:04 2010
New Revision: 48850
URL: https://trac.parrot.org/parrot/changeset/48850
Log:
[hash] Sprinkled around some nice consts.
Modified:
branches/hash_inlined_func/src/hash.c
Modified: branches/hash_inlined_func/src/hash.c
==============================================================================
--- branches/hash_inlined_func/src/hash.c Wed Sep 8 02:12:50 2010 (r48849)
+++ branches/hash_inlined_func/src/hash.c Wed Sep 8 02:27:04 2010 (r48850)
@@ -1250,19 +1250,16 @@
{
ASSERT_ARGS(parrot_hash_get_bucket)
DECL_CONST_CAST;
-
- size_t hashval;
HashBucket *bucket;
if (hash->entries <= 0)
return NULL;
- if (hash->key_type == Hash_key_type_STRING)
- {
- STRING * const s = (STRING *)PARROT_const_cast(void *, key);
+ if (hash->key_type == Hash_key_type_STRING) {
+ STRING * const s = (STRING *)PARROT_const_cast(void *, key);
+ const size_t hashval = key_hash_STRING(interp, s, hash->seed);
- hashval = key_hash_STRING(interp, s, hash->seed);
- bucket = hash->index[hashval & hash->mask];
+ bucket = hash->index[hashval & hash->mask];
while (bucket) {
const STRING *s2 = (const STRING *)bucket->key;
@@ -1270,8 +1267,8 @@
if (s == s2)
break;
/* manually inline hash_compare_string */
- if (hashval == s2->hashval){
- if (s->encoding == s2->encoding){
+ if (hashval == s2->hashval) {
+ if (s->encoding == s2->encoding) {
if ((s->bufused == s2->bufused)
&& (memcmp(s->strstart, s2->strstart, s->bufused) == 0))
break;
@@ -1284,8 +1281,9 @@
}
}
else {
- hashval = key_hash(interp, hash, PARROT_const_cast(void *, key));
- bucket = hash->index[hashval & hash->mask];
+ const size_t hashval = key_hash(interp, hash,
+ PARROT_const_cast(void *, key));
+ bucket = hash->index[hashval & hash->mask];
while (bucket) {
if (hash_compare(interp, hash,
@@ -1362,22 +1360,21 @@
ARGIN_NULLOK(void *key), ARGIN_NULLOK(void *value))
{
ASSERT_ARGS(parrot_hash_put)
- size_t hashval;
HashBucket *bucket;
+ size_t hashval;
- if (hash->key_type == Hash_key_type_STRING)
- {
- STRING *s = (STRING *)key;
- hashval = key_hash_STRING(interp, s, hash->seed);
- bucket = hash->index[hashval & hash->mask];
+ if (hash->key_type == Hash_key_type_STRING) {
+ const STRING * const s = (STRING *)key;
+ hashval = key_hash_STRING(interp, s, hash->seed);
+ bucket = hash->index[hashval & hash->mask];
while (bucket) {
const STRING *s2 = (const STRING *)bucket->key;
if (s == s2)
break;
/* manually inline hash_compare_string */
- if (hashval == s2->hashval){
- if (s->encoding == s2->encoding){
+ if (hashval == s2->hashval) {
+ if (s->encoding == s2->encoding) {
if ((s->bufused == s2->bufused)
&& (memcmp(s->strstart, s2->strstart, s->bufused) == 0))
break;
@@ -1414,10 +1411,10 @@
/* Add the value to the new bucket, increasing the count of elements */
++hash->entries;
- hash->free_list = bucket->next;
- bucket->key = key;
- bucket->value = value;
- bucket->next = hash->index[hashval & hash->mask];
+ hash->free_list = bucket->next;
+ bucket->key = key;
+ bucket->value = value;
+ bucket->next = hash->index[hashval & hash->mask];
hash->index[hashval & hash->mask] = bucket;
}
More information about the parrot-commits
mailing list