aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2012-01-23 16:46:53 +0100
committerSverker Eriksson <[email protected]>2012-02-21 12:23:01 +0100
commit48e662a63e80c4f358be1ba062615ff56e09f331 (patch)
treea253cb707b95528e46137654e667426ea223e465 /erts
parent194ae0717f9be27374db3609e6884fad086df4df (diff)
downloadotp-48e662a63e80c4f358be1ba062615ff56e09f331.tar.gz
otp-48e662a63e80c4f358be1ba062615ff56e09f331.tar.bz2
otp-48e662a63e80c4f358be1ba062615ff56e09f331.zip
erts: Refactor new function index_put_entry()
Same as index_put() but returns pointer to entry instead of index integer.
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/index.c8
-rw-r--r--erts/emulator/beam/index.h10
-rw-r--r--erts/emulator/beam/module.c6
3 files changed, 15 insertions, 9 deletions
diff --git a/erts/emulator/beam/index.c b/erts/emulator/beam/index.c
index 7cd45440f4..25d5cce0f3 100644
--- a/erts/emulator/beam/index.c
+++ b/erts/emulator/beam/index.c
@@ -68,14 +68,14 @@ erts_index_init(ErtsAlcType_t type, IndexTable* t, char* name,
return t;
}
-int
-index_put(IndexTable* t, void* tmpl)
+IndexSlot*
+index_put_entry(IndexTable* t, void* tmpl)
{
int ix;
IndexSlot* p = (IndexSlot*) hash_put(&t->htable, tmpl);
if (p->index >= 0) {
- return p->index;
+ return p;
}
ix = t->entries;
@@ -92,7 +92,7 @@ index_put(IndexTable* t, void* tmpl)
t->entries++;
p->index = ix;
t->seg_table[ix>>INDEX_PAGE_SHIFT][ix&INDEX_PAGE_MASK] = p;
- return ix;
+ return p;
}
int index_get(IndexTable* t, void* tmpl)
diff --git a/erts/emulator/beam/index.h b/erts/emulator/beam/index.h
index 69d1cc0a22..3afe48d007 100644
--- a/erts/emulator/beam/index.h
+++ b/erts/emulator/beam/index.h
@@ -55,16 +55,24 @@ void index_info(int, void *, IndexTable*);
int index_table_sz(IndexTable *);
int index_get(IndexTable*, void*);
-int index_put(IndexTable*, void*);
+
+IndexSlot* index_put_entry(IndexTable*, void*);
void erts_index_merge(Hash*, IndexTable*);
/* Erase all entries with index 'ix' and higher
*/
void index_erase_latest_from(IndexTable*, Uint ix);
+ERTS_GLB_INLINE int index_put(IndexTable*, void*);
ERTS_GLB_INLINE IndexSlot* erts_index_lookup(IndexTable*, Uint);
#if ERTS_GLB_INLINE_INCL_FUNC_DEF
+
+ERTS_GLB_INLINE int index_put(IndexTable* t, void* tmpl)
+{
+ return index_put_entry(t, tmpl)->index;
+}
+
ERTS_GLB_INLINE IndexSlot*
erts_index_lookup(IndexTable* t, Uint ix)
{
diff --git a/erts/emulator/beam/module.c b/erts/emulator/beam/module.c
index ab4f387982..f326aecebf 100644
--- a/erts/emulator/beam/module.c
+++ b/erts/emulator/beam/module.c
@@ -122,7 +122,6 @@ Module*
erts_put_module(Eterm mod)
{
Module e;
- int index;
IndexTable* mod_tab;
ASSERT(is_atom(mod));
@@ -132,8 +131,7 @@ erts_put_module(Eterm mod)
mod_tab = &module_tables[erts_loader_code_ix()];
e.module = atom_val(mod);
- index = index_put(mod_tab, (void*) &e);
- return (Module*) erts_index_lookup(mod_tab, index);
+ return (Module*) index_put_entry(mod_tab, (void*) &e);
}
Module *module_code(int i, ErtsCodeIndex code_ix)
@@ -185,7 +183,7 @@ void module_start_load(void)
*/
for (i = dst->entries; i < src->entries; i++) {
src_mod = (Module*) erts_index_lookup(src, i);
- dst_mod = (Module*) erts_index_lookup(dst, index_put(dst, src_mod));
+ dst_mod = (Module*) index_put_entry(dst, src_mod);
ASSERT(dst_mod != src_mod);
dst_mod->curr = src_mod->curr;