Use ImmutableString for HLSL texture references
This also adds ImmutableStringBuilder class, which can be used to
build ImmutableStrings in place without extra allocations if the
maximum length is known in advance.
BUG=angleproject:2267
TEST=angle_unittests
Change-Id: I4dfb78adeb0cffcfad0d25753fb8063466012c92
Reviewed-on: https://chromium-review.googlesource.com/886362
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/ImmutableString.h b/src/compiler/translator/ImmutableString.h
index 2957944..a33fec9 100644
--- a/src/compiler/translator/ImmutableString.h
+++ b/src/compiler/translator/ImmutableString.h
@@ -45,10 +45,13 @@
{
}
+ constexpr ImmutableString(const char *data, size_t length) : mData(data), mLength(length) {}
+
ImmutableString(const ImmutableString &) = default;
ImmutableString &operator=(const ImmutableString &) = default;
const char *data() const { return mData ? mData : ""; }
+ size_t length() const { return mLength; }
bool operator<(const ImmutableString &b) const
{
@@ -64,10 +67,12 @@
}
private:
- const char *const mData;
- const size_t mLength;
+ const char *mData;
+ size_t mLength;
};
} // namespace sh
+std::ostream &operator<<(std::ostream &os, const sh::ImmutableString &str);
+
#endif // COMPILER_TRANSLATOR_IMMUTABLESTRING_H_