forked from qt-creator/qt-creator
Clang: Return ClangString instead of Utf8String
Utf8String is allocating memory but for many compares it is not needed. In an inner loop this can be expensive. Change-Id: I6320823ab7e086008447eea255e52859a7faaad7 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <utf8string.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <ostream>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
@@ -85,6 +86,11 @@ public:
|
||||
return cxString.data == nullptr;
|
||||
}
|
||||
|
||||
bool hasContent() const
|
||||
{
|
||||
return !isNull() && std::strlen(cString()) > 0;
|
||||
}
|
||||
|
||||
friend bool operator==(const ClangString &first, const ClangString &second)
|
||||
{
|
||||
return std::strcmp(first.cString(), second.cString()) == 0;
|
||||
@@ -118,6 +124,13 @@ public:
|
||||
return second == first;
|
||||
}
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &out, const ClangString &string)
|
||||
{
|
||||
out << string.cString();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
private:
|
||||
CXString cxString;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user