summaryrefslogtreecommitdiff
path: root/lib/element.cpp
diff options
context:
space:
mode:
authorJosh Blum2013-06-11 01:13:13 -0700
committerJosh Blum2013-06-11 01:13:13 -0700
commitb4fd0de25507f693a65274615bfedf648a214cba (patch)
treec22e3ab3a95099713af5d3ce69d85935e1ce77f0 /lib/element.cpp
parent41c8e89795675cd0989aee8e88647abd941c000c (diff)
downloadsandhi-b4fd0de25507f693a65274615bfedf648a214cba.tar.gz
sandhi-b4fd0de25507f693a65274615bfedf648a214cba.tar.bz2
sandhi-b4fd0de25507f693a65274615bfedf648a214cba.zip
gras: mess with default uid formatting
Diffstat (limited to 'lib/element.cpp')
-rw-r--r--lib/element.cpp13
1 files changed, 4 insertions, 9 deletions
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 <boost/format.hpp>
#include <boost/foreach.hpp>
#include <boost/algorithm/string.hpp>
-#include <boost/functional/hash.hpp>
#include <cstdlib>
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<std::string> 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;
}