From 5eb8989192445b0505933fcdb1c4f489d4bdc7f9 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 23 Oct 2014 13:53:04 +0100 Subject: [PATCH] Fix slow InternedString copy constructor --- src/interned_string.hh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/interned_string.hh b/src/interned_string.hh index d21ce26f..b280fde9 100644 --- a/src/interned_string.hh +++ b/src/interned_string.hh @@ -31,7 +31,11 @@ class InternedString : public StringView public: InternedString() = default; - InternedString(const InternedString& str) { acquire_ifn(str); } + InternedString(const InternedString& str) : InternedString(str, str.m_slot) + { + if (m_slot != -1) + StringRegistry::instance().acquire(m_slot); + } InternedString(InternedString&& str) : StringView(str) { @@ -71,11 +75,6 @@ public: release_ifn(); } - bool operator==(const InternedString& str) const - { return data() == str.data() && length() == str.length(); } - bool operator!=(const InternedString& str) const - { return !(*this == str); } - using StringView::operator==; using StringView::operator!=;