mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
only call expensive wstring_convert() when necessary
This commit is contained in:
@@ -201,7 +201,18 @@ namespace {
|
||||
builder_.push_back('\'');
|
||||
|
||||
if (mode == IfcParse::IfcCharacterDecoder::UTF8) {
|
||||
return IfcUtil::convert_utf8(builder_);
|
||||
if (builder_.empty()) {
|
||||
static std::string empty;
|
||||
return empty;
|
||||
} else {
|
||||
auto it = std::max_element(builder_.begin(), builder_.end());
|
||||
if (*it <= 0x7e) {
|
||||
std::string r(builder_.begin(), builder_.end());
|
||||
return r;
|
||||
} else {
|
||||
return IfcUtil::convert_utf8(builder_);
|
||||
}
|
||||
}
|
||||
} else if (mode == IfcParse::IfcCharacterDecoder::SUBSTITUTE) {
|
||||
std::string r;
|
||||
r.reserve(builder_.size());
|
||||
|
||||
Reference in New Issue
Block a user