From d0b67cb5671ff3833001e133cf8bbe1cdbb0c601 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 7 Jun 2010 16:30:21 +0200 Subject: [PATCH] reduced the amount of new in reclists --- game/esm_store/reclists.hpp | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/game/esm_store/reclists.hpp b/game/esm_store/reclists.hpp index ca0e47767..bd04ad3c5 100644 --- a/game/esm_store/reclists.hpp +++ b/game/esm_store/reclists.hpp @@ -21,24 +21,14 @@ namespace ESMS template struct RecListT : RecList { - typedef std::map MapType; + typedef std::map MapType; MapType list; // Load one object of this type void load(ESMReader &esm, const std::string &id) { - X *ref; - - if(list.find(id) == list.end()) - { - ref = new X; - list[id] = ref; - } - else - ref = list[id]; - - ref->load(esm); + list[id].load(esm); } // Find the given object ID, or return NULL if not found. @@ -46,7 +36,7 @@ namespace ESMS { if(list.find(id) == list.end()) return NULL; - return list.find(id)->second; + return &list.find(id)->second; } int getSize() { return list.size(); } @@ -58,24 +48,16 @@ namespace ESMS template struct RecIDListT : RecList { - typedef std::map MapType; + typedef std::map MapType; MapType list; void load(ESMReader &esm, const std::string &id) { - X *ref; - - if(list.find(id) == list.end()) - { - ref = new X; - list[id] = ref; - } - else - ref = list[id]; + X& ref = list[id]; - ref->id = id; - ref->load(esm); + ref.id = id; + ref.load(esm); } int getSize() { return list.size(); }