Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShahbaz Youssefi <syoussefi@google.com>2022-09-30 22:24:48 +0300
committerGitHub <noreply@github.com>2022-09-30 22:24:48 +0300
commit4dbc66380dd63aabbd33c38198008449d0a5807a (patch)
treeebb3000840bb0576aaa5238bf76366c9b76ad6ec
parent07d361b6755c00922b30e6e20e8ae3797e78dd58 (diff)
spirv-val: Use ostringstream in id validation tests (#4956)
Proved to be marginally faster than appending to string.
-rw-r--r--test/val/val_id_test.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/test/val/val_id_test.cpp b/test/val/val_id_test.cpp
index e103a17ea..dd040b33e 100644
--- a/test/val/val_id_test.cpp
+++ b/test/val/val_id_test.cpp
@@ -196,7 +196,7 @@ std::string ValidateIdWithMessage::make_message(const char* msg) {
}
std::string message(msg);
- std::string result;
+ std::ostringstream result;
size_t next = 0;
while (next < message.size()) {
@@ -204,13 +204,13 @@ std::string ValidateIdWithMessage::make_message(const char* msg) {
size_t open_quote = message.find('\'', next);
// Copy up to the first quote
- result.append(message, next, open_quote - next);
+ result.write(msg + next, open_quote - next);
if (open_quote == std::string::npos) {
break;
}
// Handle apostrophes
if (!isdigit(message[open_quote + 1])) {
- result.append("'");
+ result << '\'';
next = open_quote + 1;
continue;
}
@@ -225,17 +225,16 @@ std::string ValidateIdWithMessage::make_message(const char* msg) {
assert(close_quote < message.size() && message[close_quote] == '\'');
// Change to 'num[%num]' because friendly names are not being used.
- result.append(message, open_quote, open_bracket - open_quote + 1); // 'num[
- result.append("%"); // %
- result.append(message, open_quote + 1,
- open_bracket - open_quote - 1); // num
- result.append("]'"); // ]'
+ result.write(msg + open_quote, open_bracket - open_quote + 1);
+ result << '%';
+ result.write(msg + open_quote + 1, open_bracket - open_quote - 1);
+ result << "]'";
// Continue to the next id, or end of string.
next = close_quote + 1;
}
- return result;
+ return result.str();
}
// TODO: OpUndef