diff options
author | shennetsind <ind@henn.et> | 2013-12-17 23:02:13 -0200 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-12-17 23:02:13 -0200 |
commit | 38f6b2c68c59d3ed2e3fc6d4d75907939c4fdf61 (patch) | |
tree | 45b4bf49bca0ffb5fabe7405f445caa22cc215f8 /src/map | |
parent | 46a990697bdacaf3955c54e0b9d8503f3b704728 (diff) | |
download | hercules-38f6b2c68c59d3ed2e3fc6d4d75907939c4fdf61.tar.gz hercules-38f6b2c68c59d3ed2e3fc6d4d75907939c4fdf61.tar.bz2 hercules-38f6b2c68c59d3ed2e3fc6d4d75907939c4fdf61.tar.xz hercules-38f6b2c68c59d3ed2e3fc6d4d75907939c4fdf61.zip |
Speed up of several procedures that rely on ERS, _mreallocz ('z'ero)
Made Possible Thanks to the Woonderful Haruna! <3
Commit also fixes an inconsistency in the ERS, where it'd start with clear memory but would use garbage upon resizing, also implements a new ERS option that clears entries as soon as pass by ers_free, so that they'll be all shinny for when ers_alloc reuses them.
Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/map.c | 4 | ||||
-rw-r--r-- | src/map/mapreg_sql.c | 2 | ||||
-rw-r--r-- | src/map/mob.c | 3 | ||||
-rw-r--r-- | src/map/script.c | 3 | ||||
-rw-r--r-- | src/map/skill.c | 9 |
5 files changed, 8 insertions, 13 deletions
diff --git a/src/map/map.c b/src/map/map.c index 3a018828a..7ff4ebcc5 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5551,9 +5551,9 @@ int do_init(int argc, char *argv[]) map->iwall_db = strdb_alloc(DB_OPT_RELEASE_DATA,2*NAME_LENGTH+2+1); // [Zephyrus] Invisible Walls map->zone_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAP_ZONE_NAME_LENGTH); - map->iterator_ers = ers_new(sizeof(struct s_mapiterator),"map.c::map_iterator_ers",ERS_OPT_NONE); + map->iterator_ers = ers_new(sizeof(struct s_mapiterator),"map.c::map_iterator_ers",ERS_OPT_CLEAN); - map->flooritem_ers = ers_new(sizeof(struct flooritem_data),"map.c::map_flooritem_ers",ERS_OPT_NONE); + map->flooritem_ers = ers_new(sizeof(struct flooritem_data),"map.c::map_flooritem_ers",ERS_OPT_CLEAN); ers_chunk_size(map->flooritem_ers, 100); if (!minimal) { diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index c94e42d5d..6a13ef2a0 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -291,7 +291,7 @@ void mapreg_final(void) { void mapreg_init(void) { mapreg->db = idb_alloc(DB_OPT_BASE); mapreg->str_db = idb_alloc(DB_OPT_BASE); - mapreg->ers = ers_new(sizeof(struct mapreg_save), "mapreg_sql.c::mapreg_ers", ERS_OPT_NONE); + mapreg->ers = ers_new(sizeof(struct mapreg_save), "mapreg_sql.c::mapreg_ers", ERS_OPT_CLEAN); mapreg->load(); diff --git a/src/map/mob.c b/src/map/mob.c index 90a967d61..d919e7478 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1768,7 +1768,6 @@ int mob_ai_hard(int tid, int64 tick, int id, intptr_t data) { *------------------------------------------*/ struct item_drop* mob_setdropitem(int nameid, int qty, struct item_data *data) { struct item_drop *drop = ers_alloc(item_drop_ers, struct item_drop); - memset(&drop->item_data, 0, sizeof(struct item)); drop->item_data.nameid = nameid; drop->item_data.amount = qty; drop->item_data.identify = data ? itemdb->isidentified2(data) : itemdb->isidentified(nameid); @@ -4642,7 +4641,7 @@ int do_init_mob(bool minimal) { memset(mob->db_data,0,sizeof(mob->db_data)); //Clear the array mob->db_data[0] = (struct mob_db*)aCalloc(1, sizeof (struct mob_db)); //This mob is used for random spawns mob->makedummymobdb(0); //The first time this is invoked, it creates the dummy mob - item_drop_ers = ers_new(sizeof(struct item_drop),"mob.c::item_drop_ers",ERS_OPT_NONE); + item_drop_ers = ers_new(sizeof(struct item_drop),"mob.c::item_drop_ers",ERS_OPT_CLEAN); item_drop_list_ers = ers_new(sizeof(struct item_drop_list),"mob.c::item_drop_list_ers",ERS_OPT_NONE); mob->load(minimal); diff --git a/src/map/script.c b/src/map/script.c index aa8ac7f63..074348ef0 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2940,7 +2940,6 @@ struct script_state* script_alloc_state(struct script_code* rootscript, int pos, struct script_state* st; st = ers_alloc(script->st_ers, struct script_state); - memset(st, 0, sizeof(struct script_state)); st->stack = ers_alloc(script->stack_ers, struct script_stack); st->stack->sp = 0; st->stack->sp_max = 64; @@ -4013,7 +4012,7 @@ void do_init_script(bool minimal) { script->userfunc_db = strdb_alloc(DB_OPT_DUP_KEY,0); script->autobonus_db = strdb_alloc(DB_OPT_DUP_KEY,0); - script->st_ers = ers_new(sizeof(struct script_state), "script.c::st_ers", ERS_OPT_NONE); + script->st_ers = ers_new(sizeof(struct script_state), "script.c::st_ers", ERS_OPT_CLEAN); script->stack_ers = ers_new(sizeof(struct script_stack), "script.c::script_stack", ERS_OPT_NONE); ers_chunk_size(script->st_ers, 10); diff --git a/src/map/skill.c b/src/map/skill.c index 6893a9f57..71e343db0 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -17141,10 +17141,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) if( !(cd = idb_get(skill->cd_db,sd->status.char_id)) ) {// create a new skill cooldown object for map storage cd = ers_alloc(skill->cd_ers, struct skill_cd); - - cd->cursor = 0; - memset(cd->entry, 0, sizeof(cd->entry)); - + idb_put( skill->cd_db, sd->status.char_id, cd ); } else { int i; @@ -18215,9 +18212,9 @@ int do_init_skill(bool minimal) { skill->cd_db = idb_alloc(DB_OPT_BASE); skill->usave_db = idb_alloc(DB_OPT_RELEASE_DATA); - skill->unit_ers = ers_new(sizeof(struct skill_unit_group),"skill.c::skill_unit_ers",ERS_OPT_NONE); + skill->unit_ers = ers_new(sizeof(struct skill_unit_group),"skill.c::skill_unit_ers",ERS_OPT_CLEAN); skill->timer_ers = ers_new(sizeof(struct skill_timerskill),"skill.c::skill_timer_ers",ERS_OPT_NONE); - skill->cd_ers = ers_new(sizeof(struct skill_cd),"skill.c::skill_cd_ers",ERS_OPT_CLEAR); + skill->cd_ers = ers_new(sizeof(struct skill_cd),"skill.c::skill_cd_ers",ERS_OPT_CLEAR|ERS_OPT_CLEAN); skill->cd_entry_ers = ers_new(sizeof(struct skill_cd_entry),"skill.c::skill_cd_entry_ers",ERS_OPT_CLEAR); ers_chunk_size(skill->cd_ers, 25); |