summaryrefslogtreecommitdiffstats
path: root/libs/utils/String8.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/utils/String8.cpp')
-rw-r--r--libs/utils/String8.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/libs/utils/String8.cpp b/libs/utils/String8.cpp
index 562f026..e852d77 100644
--- a/libs/utils/String8.cpp
+++ b/libs/utils/String8.cpp
@@ -20,11 +20,8 @@
#include <utils/Unicode.h>
#include <utils/SharedBuffer.h>
#include <utils/String16.h>
-#include <utils/TextOutput.h>
#include <utils/threads.h>
-#include <private/utils/Static.h>
-
#include <ctype.h>
/*
@@ -46,6 +43,8 @@ static char* gEmptyString = NULL;
extern int gDarwinCantLoadAllObjects;
int gDarwinIsReallyAnnoying;
+void initialize_string8();
+
static inline char* getEmptyString()
{
gEmptyStringBuf->acquire();
@@ -143,6 +142,19 @@ String8::String8()
{
}
+String8::String8(StaticLinkage)
+ : mString(0)
+{
+ // this constructor is used when we can't rely on the static-initializers
+ // having run. In this case we always allocate an empty string. It's less
+ // efficient than using getEmptyString(), but we assume it's uncommon.
+
+ char* data = static_cast<char*>(
+ SharedBuffer::alloc(sizeof(char))->data());
+ data[0] = 0;
+ mString = data;
+}
+
String8::String8(const String8& o)
: mString(o.mString)
{
@@ -450,12 +462,6 @@ void String8::getUtf32(char32_t* dst) const
utf8_to_utf32(mString, length(), dst);
}
-TextOutput& operator<<(TextOutput& to, const String8& val)
-{
- to << val.string();
- return to;
-}
-
// ---------------------------------------------------------------------------
// Path functions