diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-05-19 22:15:02 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-05-19 22:15:02 +0800 |
commit | b48167dec0c1c05b463991a8db5a8db70a5ae604 (patch) | |
tree | eadc95ab546a617d298fb3a16fb080e1bc4355e8 /src/trans/mangling.cpp | |
parent | dab5cf5462d8fce6d6fcaa1343df8f5f3b763b8a (diff) | |
download | mrust-b48167dec0c1c05b463991a8db5a8db70a5ae604.tar.gz |
All - Switch to using interned (de-duplicated) RcString-s instead of std::string for paths/identifiers
Diffstat (limited to 'src/trans/mangling.cpp')
-rw-r--r-- | src/trans/mangling.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/trans/mangling.cpp b/src/trans/mangling.cpp index 741d13dd..5d7584ed 100644 --- a/src/trans/mangling.cpp +++ b/src/trans/mangling.cpp @@ -22,18 +22,27 @@ #include <hir/path.hpp> namespace { - ::std::string escape_str(const ::std::string& s) { + ::std::string escape_str(const char* s, size_t len) { ::std::string output; - output.reserve(s.size() + 1); - for(auto v : s) + output.reserve(len + 1); + for(auto vp = s; vp != s + len; vp ++) + { + auto v= *vp; if( v == '#' ) output += "$H"; else if( v == '-' ) output += "_"; else output += v; + } return output; } + ::std::string escape_str(const RcString& s) { + return escape_str(s.c_str(), s.size()); + } + ::std::string escape_str(const ::std::string& s) { + return escape_str(s.c_str(), s.size()); + } ::FmtLambda emit_params(const ::HIR::PathParams& params) { return FMT_CB(ss, |