From b4fd0de25507f693a65274615bfedf648a214cba Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 11 Jun 2013 01:13:13 -0700 Subject: gras: mess with default uid formatting --- lib/element.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'lib/element.cpp') diff --git a/lib/element.cpp b/lib/element.cpp index 4b73bd4..2de0ffb 100644 --- a/lib/element.cpp +++ b/lib/element.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include using namespace gras; @@ -19,12 +18,10 @@ Element::Element(const std::string &name) { this->reset(new ElementImpl()); (*this)->name = name; - std::string extra; - std::string uid = name; - boost::hash string_hash; - std::size_t h = string_hash(uid); + size_t which = 0; while (true) { + const std::string uid = str(boost::format("%s %u") % name % which); try { this->set_uid(uid); @@ -32,12 +29,10 @@ Element::Element(const std::string &name) } catch(const std::invalid_argument &ex) { - extra = str(boost::format("%04x") % short(h++)); - uid = name+" "+extra; + which++; } } - if (not extra.empty()) (*this)->repr = name; - else (*this)->repr = str(boost::format("%s (%s)") % name % extra); + (*this)->repr = str(boost::format("%s (%u)") % name % which); if (GENESIS) std::cerr << "New element: " << to_string() << std::endl; } -- cgit