[前][次][番号順一覧][スレッド一覧]

ruby-changes:39357

From: normal <ko1@a...>
Date: Thu, 30 Jul 2015 08:55:44 +0900 (JST)
Subject: [ruby-changes:39357] normal:r51438 (trunk): st.c: constify st_table* in private functions

normal	2015-07-30 08:55:23 +0900 (Thu, 30 Jul 2015)

  New Revision: 51438

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51438

  Log:
    st.c: constify st_table* in private functions
    
    Minor size reduction on 32-bit x86:
    
       text	   data	    bss	    dec	    hex	filename
      13742	     24	      0	  13766	   35c6	st.o
      14166	     24	      0	  14190	   376e	st-orig.o
    
    Public API change to be proposed separately.
    
    * st.c (find_entry): constify st_table*
      (find_packed_index_from): ditto
      (find_packed_index): ditto
      (get_keys): ditto
      (get_values): ditto

  Modified files:
    trunk/ChangeLog
    trunk/st.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51437)
+++ ChangeLog	(revision 51438)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jul 30 08:48:42 2015  Eric Wong  <e@8...>
+
+	* st.c (find_entry): constify st_table*
+	  (find_packed_index_from): ditto
+	  (find_packed_index): ditto
+	  (get_keys): ditto
+	  (get_values): ditto
+
 Thu Jul 30 04:29:25 2015  Eric Wong  <e@8...>
 
 	* benchmark/bm_hash_aref_dsym.rb: new benchmark
Index: st.c
===================================================================
--- st.c	(revision 51437)
+++ st.c	(revision 51438)
@@ -347,7 +347,8 @@ count_collision(const struct st_hash_typ https://github.com/ruby/ruby/blob/trunk/st.c#L347
     ((ptr) = find_entry((table), key, (hash_val), ((bin_pos) = hash_pos(hash_val, (table)->num_bins))))
 
 static st_table_entry *
-find_entry(st_table *table, st_data_t key, st_index_t hash_val, st_index_t bin_pos)
+find_entry(const st_table *table, st_data_t key, st_index_t hash_val,
+           st_index_t bin_pos)
 {
     register st_table_entry *ptr = table->bins[bin_pos];
     FOUND_ENTRY;
@@ -362,7 +363,8 @@ find_entry(st_table *table, st_data_t ke https://github.com/ruby/ruby/blob/trunk/st.c#L363
 }
 
 static inline st_index_t
-find_packed_index_from(st_table *table, st_index_t hash_val, st_data_t key, st_index_t i)
+find_packed_index_from(const st_table *table, st_index_t hash_val,
+		       st_data_t key, st_index_t i)
 {
     while (i < table->real_entries &&
 	   (PHASH(table, i) != hash_val || !EQUAL(table, key, &PACKED_ENT(table, i)))) {
@@ -372,7 +374,7 @@ find_packed_index_from(st_table *table, https://github.com/ruby/ruby/blob/trunk/st.c#L374
 }
 
 static inline st_index_t
-find_packed_index(st_table *table, st_index_t hash_val, st_data_t key)
+find_packed_index(const st_table *table, st_index_t hash_val, st_data_t key)
 {
     return find_packed_index_from(table, hash_val, key, 0);
 }
@@ -1038,7 +1040,8 @@ st_foreach(st_table *table, int (*func)( https://github.com/ruby/ruby/blob/trunk/st.c#L1040
 }
 
 static st_index_t
-get_keys(st_table *table, st_data_t *keys, st_index_t size, int check, st_data_t never)
+get_keys(const st_table *table, st_data_t *keys, st_index_t size,
+         int check, st_data_t never)
 {
     st_data_t key;
     st_data_t *keys_start = keys;
@@ -1081,7 +1084,8 @@ st_keys_check(st_table *table, st_data_t https://github.com/ruby/ruby/blob/trunk/st.c#L1084
 }
 
 static st_index_t
-get_values(st_table *table, st_data_t *values, st_index_t size, int check, st_data_t never)
+get_values(const st_table *table, st_data_t *values, st_index_t size,
+           int check, st_data_t never)
 {
     st_data_t key;
     st_data_t *values_start = values;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]