From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] st.c: constify st_table in private functions
Date: Wed, 29 Jul 2015 23:43:49 +0000 [thread overview]
Message-ID: <1438213429-24040-1-git-send-email-e@80x24.org> (raw)
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 coming
---
st.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/st.c b/st.c
index 0125132..9b79704 100644
--- a/st.c
+++ b/st.c
@@ -347,7 +347,8 @@ count_collision(const struct st_hash_type *type)
((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 key, st_index_t hash_val, st_index_t bin_p
}
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, st_index_t hash_val, st_data_t key, st_i
}
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)(ANYARGS), st_data_t arg)
}
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 *keys, st_index_t size, st_data_t never
}
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;
--
EW
reply other threads:[~2015-07-29 23:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438213429-24040-1-git-send-email-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).