diff options
author | 2017-03-30 20:20:00 +0200 | |
---|---|---|
committer | 2017-03-30 22:06:03 +0200 | |
commit | ac13946ffbec538f5fc193843fae7dd513b9c58e (patch) | |
tree | 44ee3cdb306b6cbd214c12bd8cb46dc1e6e6fb19 /src/lib/netlist/prg/nltool.cpp | |
parent | ac856bc4d1d22a4be0cd8c86ec7da66761becc96 (diff) |
Change pstring to use std::string as storage container.
This removes all allocation code from pstring. const_iterator is
consequently now based on pstring::const_iterator.
Removed pstring_buffer. This was class wasn't a good idea.
Vas was right: This change did not impact runtime performance. Startup
performance (string intensive) increased. (nw)
Diffstat (limited to 'src/lib/netlist/prg/nltool.cpp')
-rw-r--r-- | src/lib/netlist/prg/nltool.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp index ba0526b5408..bde2bcd5b6c 100644 --- a/src/lib/netlist/prg/nltool.cpp +++ b/src/lib/netlist/prg/nltool.cpp @@ -421,7 +421,7 @@ void tool_app_t::mac_out(const pstring &s, const bool cont) if (cont) { unsigned adj = 0; - for (auto &x : s) + for (const auto &x : s) adj += (x == '\t' ? 3 : 0); pout("{1}\\\n", s.rpad(" ", RIGHT-1-adj)); } @@ -434,13 +434,13 @@ void tool_app_t::cmac(const netlist::factory::element_t *e) auto v = plib::psplit(e->param_desc(), ","); pstring vs; for (auto s : v) - vs += ", p" + s.replace("+","").replace(".","_"); + vs += ", p" + s.replace_all("+", "").replace_all(".", "_"); mac_out("#define " + e->name() + "(name" + vs + ")"); mac_out("\tNET_REGISTER_DEV(" + e->name() +", name)"); for (auto s : v) { - pstring r(s.replace("+","").replace(".","_")); + pstring r(s.replace_all("+", "").replace_all(".", "_")); if (s.startsWith("+")) mac_out("\tNET_CONNECT(name, " + r + ", p" + r + ")"); else @@ -455,7 +455,7 @@ void tool_app_t::mac(const netlist::factory::element_t *e) pstring vs; for (auto s : v) { - vs += ", " + s.replace("+","").replace(".","_"); + vs += ", " + s.replace_all("+", "").replace_all(".", "_"); } pout("{1}(name{2})\n", e->name(), vs); if (v.size() > 0) @@ -463,7 +463,7 @@ void tool_app_t::mac(const netlist::factory::element_t *e) pout("/*\n"); for (auto s : v) { - pstring r(s.replace("+","").replace(".","_")); + pstring r(s.replace_all("+", "").replace_all(".", "_")); if (s.startsWith("+")) pout("{1:10}: Terminal\n",r); else @@ -507,7 +507,7 @@ void tool_app_t::create_header() { last_source = e->sourcefile(); pout("{1}\n", pstring("// ").rpad("-", 72)); - pout("{1}\n", pstring("// Source: ").cat(e->sourcefile().replace("../",""))); + pout("{1}{2}\n", pstring("// Source: "), e->sourcefile().replace_all("../", "")); pout("{1}\n", pstring("// ").rpad("-", 72)); } cmac(e.get()); @@ -603,7 +603,7 @@ void tool_app_t::listdevices() if (t.second->name().startsWith(d->name())) { pstring tn(t.second->name().substr(d->name().len()+1)); - if (tn.find(".") == tn.end()) + if (tn.find(".") == pstring::npos) terms.push_back(tn); } } @@ -614,7 +614,7 @@ void tool_app_t::listdevices() { pstring tn(t.first.substr(d->name().len()+1)); //printf("\t%s %s %s\n", t.first.c_str(), t.second.c_str(), tn.c_str()); - if (tn.find(".") == tn.end()) + if (tn.find(".") == pstring::npos) { terms.push_back(tn); pstring resolved = nt.setup().resolve_alias(t.first); @@ -770,8 +770,6 @@ int tool_app_t::execute() { perr("plib exception caught: {}\n", e.text()); } - - pstring::resetmem(); return 0; } |