aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Antipov2012-08-20 12:07:38 +0400
committerDmitry Antipov2012-08-20 12:07:38 +0400
commite83064befad4b03bae2f873ece63c050f2c4ca22 (patch)
treebf2882b2b653b07da53a33d393c5667715e8bd4a
parent3d300447843086aa7ae4df85dd0a97f27b0b885a (diff)
downloademacs-e83064befad4b03bae2f873ece63c050f2c4ca22.tar.gz
emacs-e83064befad4b03bae2f873ece63c050f2c4ca22.zip
Inline setter functions for hash table members.
* lisp.h (set_hash_key, set_hash_value, set_hash_next) (set_hash_hash, set_hash_index): Rename with _slot suffix. (set_hash_key_and_value, set_hash_index, set_hash_next) (set_hash_hash): New functions. * charset.c, fns.c: Adjust users.
-rw-r--r--src/ChangeLog9
-rw-r--r--src/charset.c2
-rw-r--r--src/fns.c64
-rw-r--r--src/lisp.h34
4 files changed, 71 insertions, 38 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c5ab370d311..cc5b2b2eb77 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,14 @@
12012-08-20 Dmitry Antipov <dmantipov@yandex.ru> 12012-08-20 Dmitry Antipov <dmantipov@yandex.ru>
2 2
3 Inline setter functions for hash table members.
4 * lisp.h (set_hash_key, set_hash_value, set_hash_next)
5 (set_hash_hash, set_hash_index): Rename with _slot suffix.
6 (set_hash_key_and_value, set_hash_index, set_hash_next)
7 (set_hash_hash): New functions.
8 * charset.c, fns.c: Adjust users.
9
102012-08-20 Dmitry Antipov <dmantipov@yandex.ru>
11
3 Inline getter and setter functions for per-buffer values. 12 Inline getter and setter functions for per-buffer values.
4 * buffer.h (per_buffer_default, set_per_buffer_default) 13 * buffer.h (per_buffer_default, set_per_buffer_default)
5 (per_buffer_value, set_per_buffer_value): New functions. 14 (per_buffer_value, set_per_buffer_value): New functions.
diff --git a/src/charset.c b/src/charset.c
index 87c16e12008..3e286fa947d 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1131,7 +1131,7 @@ usage: (define-charset-internal ...) */)
1131 { 1131 {
1132 new_definition_p = 0; 1132 new_definition_p = 0;
1133 id = XFASTINT (CHARSET_SYMBOL_ID (args[charset_arg_name])); 1133 id = XFASTINT (CHARSET_SYMBOL_ID (args[charset_arg_name]));
1134 set_hash_value (hash_table, charset.hash_index, attrs); 1134 set_hash_value_slot (hash_table, charset.hash_index, attrs);
1135 } 1135 }
1136 else 1136 else
1137 { 1137 {
diff --git a/src/fns.c b/src/fns.c
index 443e98b2f04..79f8e233fb5 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3663,7 +3663,7 @@ make_hash_table (Lisp_Object test, Lisp_Object size, Lisp_Object rehash_size,
3663 3663
3664 /* Set up the free list. */ 3664 /* Set up the free list. */
3665 for (i = 0; i < sz - 1; ++i) 3665 for (i = 0; i < sz - 1; ++i)
3666 set_hash_next (h, i, make_number (i + 1)); 3666 set_hash_next_slot (h, i, make_number (i + 1));
3667 h->next_free = make_number (0); 3667 h->next_free = make_number (0);
3668 3668
3669 XSET_HASH_TABLE (table, h); 3669 XSET_HASH_TABLE (table, h);
@@ -3760,17 +3760,17 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
3760 } 3760 }
3761#endif 3761#endif
3762 3762
3763 h->key_and_value = larger_vector (h->key_and_value, 3763 set_hash_key_and_value (h, larger_vector (h->key_and_value,
3764 2 * (new_size - old_size), -1); 3764 2 * (new_size - old_size), -1));
3765 h->next = larger_vector (h->next, new_size - old_size, -1); 3765 set_hash_next (h, larger_vector (h->next, new_size - old_size, -1));
3766 h->hash = larger_vector (h->hash, new_size - old_size, -1); 3766 set_hash_hash (h, larger_vector (h->hash, new_size - old_size, -1));
3767 h->index = Fmake_vector (make_number (index_size), Qnil); 3767 set_hash_index (h, Fmake_vector (make_number (index_size), Qnil));
3768 3768
3769 /* Update the free list. Do it so that new entries are added at 3769 /* Update the free list. Do it so that new entries are added at
3770 the end of the free list. This makes some operations like 3770 the end of the free list. This makes some operations like
3771 maphash faster. */ 3771 maphash faster. */
3772 for (i = old_size; i < new_size - 1; ++i) 3772 for (i = old_size; i < new_size - 1; ++i)
3773 set_hash_next (h, i, make_number (i + 1)); 3773 set_hash_next_slot (h, i, make_number (i + 1));
3774 3774
3775 if (!NILP (h->next_free)) 3775 if (!NILP (h->next_free))
3776 { 3776 {
@@ -3781,7 +3781,7 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
3781 !NILP (next)) 3781 !NILP (next))
3782 last = next; 3782 last = next;
3783 3783
3784 set_hash_next (h, XFASTINT (last), make_number (old_size)); 3784 set_hash_next_slot (h, XFASTINT (last), make_number (old_size));
3785 } 3785 }
3786 else 3786 else
3787 XSETFASTINT (h->next_free, old_size); 3787 XSETFASTINT (h->next_free, old_size);
@@ -3792,8 +3792,8 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
3792 { 3792 {
3793 EMACS_UINT hash_code = XUINT (HASH_HASH (h, i)); 3793 EMACS_UINT hash_code = XUINT (HASH_HASH (h, i));
3794 ptrdiff_t start_of_bucket = hash_code % ASIZE (h->index); 3794 ptrdiff_t start_of_bucket = hash_code % ASIZE (h->index);
3795 set_hash_next (h, i, HASH_INDEX (h, start_of_bucket)); 3795 set_hash_next_slot (h, i, HASH_INDEX (h, start_of_bucket));
3796 set_hash_index (h, start_of_bucket, make_number (i)); 3796 set_hash_index_slot (h, start_of_bucket, make_number (i));
3797 } 3797 }
3798 } 3798 }
3799} 3799}
@@ -3852,16 +3852,16 @@ hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value,
3852 /* Store key/value in the key_and_value vector. */ 3852 /* Store key/value in the key_and_value vector. */
3853 i = XFASTINT (h->next_free); 3853 i = XFASTINT (h->next_free);
3854 h->next_free = HASH_NEXT (h, i); 3854 h->next_free = HASH_NEXT (h, i);
3855 set_hash_key (h, i, key); 3855 set_hash_key_slot (h, i, key);
3856 set_hash_value (h, i, value); 3856 set_hash_value_slot (h, i, value);
3857 3857
3858 /* Remember its hash code. */ 3858 /* Remember its hash code. */
3859 set_hash_hash (h, i, make_number (hash)); 3859 set_hash_hash_slot (h, i, make_number (hash));
3860 3860
3861 /* Add new entry to its collision chain. */ 3861 /* Add new entry to its collision chain. */
3862 start_of_bucket = hash % ASIZE (h->index); 3862 start_of_bucket = hash % ASIZE (h->index);
3863 set_hash_next (h, i, HASH_INDEX (h, start_of_bucket)); 3863 set_hash_next_slot (h, i, HASH_INDEX (h, start_of_bucket));
3864 set_hash_index (h, start_of_bucket, make_number (i)); 3864 set_hash_index_slot (h, start_of_bucket, make_number (i));
3865 return i; 3865 return i;
3866} 3866}
3867 3867
@@ -3892,16 +3892,16 @@ hash_remove_from_table (struct Lisp_Hash_Table *h, Lisp_Object key)
3892 { 3892 {
3893 /* Take entry out of collision chain. */ 3893 /* Take entry out of collision chain. */
3894 if (NILP (prev)) 3894 if (NILP (prev))
3895 set_hash_index (h, start_of_bucket, HASH_NEXT (h, i)); 3895 set_hash_index_slot (h, start_of_bucket, HASH_NEXT (h, i));
3896 else 3896 else
3897 set_hash_next (h, XFASTINT (prev), HASH_NEXT (h, i)); 3897 set_hash_next_slot (h, XFASTINT (prev), HASH_NEXT (h, i));
3898 3898
3899 /* Clear slots in key_and_value and add the slots to 3899 /* Clear slots in key_and_value and add the slots to
3900 the free list. */ 3900 the free list. */
3901 set_hash_key (h, i, Qnil); 3901 set_hash_key_slot (h, i, Qnil);
3902 set_hash_value (h, i, Qnil); 3902 set_hash_value_slot (h, i, Qnil);
3903 set_hash_hash (h, i, Qnil); 3903 set_hash_hash_slot (h, i, Qnil);
3904 set_hash_next (h, i, h->next_free); 3904 set_hash_next_slot (h, i, h->next_free);
3905 h->next_free = make_number (i); 3905 h->next_free = make_number (i);
3906 h->count--; 3906 h->count--;
3907 eassert (h->count >= 0); 3907 eassert (h->count >= 0);
@@ -3927,10 +3927,10 @@ hash_clear (struct Lisp_Hash_Table *h)
3927 3927
3928 for (i = 0; i < size; ++i) 3928 for (i = 0; i < size; ++i)
3929 { 3929 {
3930 set_hash_next (h, i, i < size - 1 ? make_number (i + 1) : Qnil); 3930 set_hash_next_slot (h, i, i < size - 1 ? make_number (i + 1) : Qnil);
3931 set_hash_key (h, i, Qnil); 3931 set_hash_key_slot (h, i, Qnil);
3932 set_hash_value (h, i, Qnil); 3932 set_hash_value_slot (h, i, Qnil);
3933 set_hash_hash (h, i, Qnil); 3933 set_hash_hash_slot (h, i, Qnil);
3934 } 3934 }
3935 3935
3936 for (i = 0; i < ASIZE (h->index); ++i) 3936 for (i = 0; i < ASIZE (h->index); ++i)
@@ -3994,18 +3994,18 @@ sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p)
3994 { 3994 {
3995 /* Take out of collision chain. */ 3995 /* Take out of collision chain. */
3996 if (NILP (prev)) 3996 if (NILP (prev))
3997 set_hash_index (h, bucket, next); 3997 set_hash_index_slot (h, bucket, next);
3998 else 3998 else
3999 set_hash_next (h, XFASTINT (prev), next); 3999 set_hash_next_slot (h, XFASTINT (prev), next);
4000 4000
4001 /* Add to free list. */ 4001 /* Add to free list. */
4002 set_hash_next (h, i, h->next_free); 4002 set_hash_next_slot (h, i, h->next_free);
4003 h->next_free = idx; 4003 h->next_free = idx;
4004 4004
4005 /* Clear key, value, and hash. */ 4005 /* Clear key, value, and hash. */
4006 set_hash_key (h, i, Qnil); 4006 set_hash_key_slot (h, i, Qnil);
4007 set_hash_value (h, i, Qnil); 4007 set_hash_value_slot (h, i, Qnil);
4008 set_hash_hash (h, i, Qnil); 4008 set_hash_hash_slot (h, i, Qnil);
4009 4009
4010 h->count--; 4010 h->count--;
4011 } 4011 }
@@ -4512,7 +4512,7 @@ VALUE. In any case, return VALUE. */)
4512 4512
4513 i = hash_lookup (h, key, &hash); 4513 i = hash_lookup (h, key, &hash);
4514 if (i >= 0) 4514 if (i >= 0)
4515 set_hash_value (h, i, value); 4515 set_hash_value_slot (h, i, value);
4516 else 4516 else
4517 hash_put (h, key, value, hash); 4517 hash_put (h, key, value, hash);
4518 4518
diff --git a/src/lisp.h b/src/lisp.h
index f08e7af8959..3a6eb72d020 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2345,31 +2345,55 @@ gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object val)
2345} 2345}
2346 2346
2347LISP_INLINE void 2347LISP_INLINE void
2348set_hash_key (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) 2348set_hash_key_and_value (struct Lisp_Hash_Table *h, Lisp_Object key_and_value)
2349{
2350 h->key_and_value = key_and_value;
2351}
2352
2353LISP_INLINE void
2354set_hash_key_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
2349{ 2355{
2350 gc_aset (h->key_and_value, 2 * idx, val); 2356 gc_aset (h->key_and_value, 2 * idx, val);
2351} 2357}
2352 2358
2353LISP_INLINE void 2359LISP_INLINE void
2354set_hash_value (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) 2360set_hash_value_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
2355{ 2361{
2356 gc_aset (h->key_and_value, 2 * idx + 1, val); 2362 gc_aset (h->key_and_value, 2 * idx + 1, val);
2357} 2363}
2358 2364
2359LISP_INLINE void 2365LISP_INLINE void
2360set_hash_next (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) 2366set_hash_next (struct Lisp_Hash_Table *h, Lisp_Object next)
2367{
2368 h->next = next;
2369}
2370
2371LISP_INLINE void
2372set_hash_next_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
2361{ 2373{
2362 gc_aset (h->next, idx, val); 2374 gc_aset (h->next, idx, val);
2363} 2375}
2364 2376
2365LISP_INLINE void 2377LISP_INLINE void
2366set_hash_hash (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) 2378set_hash_hash (struct Lisp_Hash_Table *h, Lisp_Object hash)
2379{
2380 h->hash = hash;
2381}
2382
2383LISP_INLINE void
2384set_hash_hash_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
2367{ 2385{
2368 gc_aset (h->hash, idx, val); 2386 gc_aset (h->hash, idx, val);
2369} 2387}
2370 2388
2371LISP_INLINE void 2389LISP_INLINE void
2372set_hash_index (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val) 2390set_hash_index (struct Lisp_Hash_Table *h, Lisp_Object index)
2391{
2392 h->index = index;
2393}
2394
2395LISP_INLINE void
2396set_hash_index_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
2373{ 2397{
2374 gc_aset (h->index, idx, val); 2398 gc_aset (h->index, idx, val);
2375} 2399}