summaryrefslogtreecommitdiff
path: root/src/strings/rstring.hpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-08-11 22:52:18 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-08-25 17:58:12 -0700
commitadd7ff74ca25ca2c9cc591abc484f8e6d38b2c39 (patch)
treec62ef1510966effdf81bec6710125b75783ff512 /src/strings/rstring.hpp
parent54df2e07fc4cc0bd8557e4152be15353ecf53d0d (diff)
downloadtmwa-add7ff74ca25ca2c9cc591abc484f8e6d38b2c39.tar.gz
tmwa-add7ff74ca25ca2c9cc591abc484f8e6d38b2c39.tar.bz2
tmwa-add7ff74ca25ca2c9cc591abc484f8e6d38b2c39.tar.xz
tmwa-add7ff74ca25ca2c9cc591abc484f8e6d38b2c39.zip
Optimize string literals in refcounted strings
Diffstat (limited to 'src/strings/rstring.hpp')
-rw-r--r--src/strings/rstring.hpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/strings/rstring.hpp b/src/strings/rstring.hpp
index fd3ee65..ad44beb 100644
--- a/src/strings/rstring.hpp
+++ b/src/strings/rstring.hpp
@@ -39,15 +39,17 @@ namespace strings
size_t size;
char body[];
};
- static
- uint8_t empty_string_rep[sizeof(Rep) + 1];
- Rep *owned;
+ union
+ {
+ Rep *owned;
+ const char *begin;
+ } u;
+ const char *maybe_end;
- template<class It>
- void _assign(It b, It e);
public:
RString();
+ RString(LString s);
RString(const RString&);
RString(RString&&);
RString& operator = (const RString&);
@@ -68,7 +70,6 @@ namespace strings
RString(XString);
template<uint8_t n>
RString(const VString<n>& v);
- RString(LString s);
iterator begin() const;
iterator end() const;