From 9d42b58aae9a9eb096b0c8a54c622331e01c20e4 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 3 Jul 2015 00:45:02 +0200 Subject: [PATCH] EntryID implementation changes for #956 - move the santitise operation up into EntryID's ctor - turn the recast() operation into a real in-place cast these changes should be transparent to the existing usages of EntryID (within the asset framework), but allow for use as attribute name holder in GenNode, since we're now able to feed existing name/ID values directly into the ctor of BareEntryID, without any spurious santitise operation. --- src/lib/idi/entry-id.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib/idi/entry-id.hpp b/src/lib/idi/entry-id.hpp index 39ee5d466..edca5c30f 100644 --- a/src/lib/idi/entry-id.hpp +++ b/src/lib/idi/entry-id.hpp @@ -133,7 +133,7 @@ namespace idi { * generates differing hash-IDs for different type parameters */ BareEntryID (string const& symbolID, HashVal seed =0) - : symbol_(util::sanitise(symbolID)) + : symbol_(symbolID) , hash_(buildHash (symbol_, seed)) { } @@ -169,7 +169,7 @@ namespace idi { template - EntryID recast() const; + EntryID const& recast() const; }; @@ -211,7 +211,7 @@ namespace idi { */ explicit EntryID (string const& symbolID) - : BareEntryID (symbolID, getTypeHash()) + : BareEntryID (util::sanitise(symbolID), getTypeHash()) { } @@ -226,14 +226,14 @@ namespace idi { return bID.getHash() == buildHash (bID.getSym(), getTypeHash()); } - static EntryID + static EntryID const& recast (BareEntryID const& bID) { if (!canRecast(bID)) throw error::Logic ("unable to recast EntryID: desired type " "doesn't match original definition" , error::LUMIERA_ERROR_WRONG_TYPE); - return EntryID (bID.getSym()); + return static_cast (bID); } @@ -268,7 +268,8 @@ namespace idi { * Exception if it doesn't match the stored hash. */ template - EntryID BareEntryID::recast() const + EntryID const& + BareEntryID::recast() const { return EntryID::recast(*this); }