Skip to content

Commit 39cf8a2

Browse files
committed
[stringref-upgrade] Use StringRef::consume_front instead of our own handrolled stripPrefix.
1 parent da10607 commit 39cf8a2

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

lib/Demangling/Remangler.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -585,15 +585,6 @@ void Remangler::mangleBoundGenericOtherNominalType(Node *node) {
585585
mangleAnyNominalType(node);
586586
}
587587

588-
template <size_t N>
589-
static bool stripPrefix(StringRef &string, const char (&data)[N]) {
590-
constexpr size_t prefixLength = N - 1;
591-
if (!string.startswith(StringRef(data, prefixLength)))
592-
return false;
593-
string = string.drop_front(prefixLength);
594-
return true;
595-
}
596-
597588
void Remangler::mangleBuiltinTypeName(Node *node) {
598589
Buffer << 'B';
599590
StringRef text = node->getText();
@@ -612,17 +603,17 @@ void Remangler::mangleBuiltinTypeName(Node *node) {
612603
Buffer << 't';
613604
} else if (text == BUILTIN_TYPE_NAME_WORD) {
614605
Buffer << 'w';
615-
} else if (stripPrefix(text, BUILTIN_TYPE_NAME_INT)) {
606+
} else if (text.consume_front(BUILTIN_TYPE_NAME_INT)) {
616607
Buffer << 'i' << text << '_';
617-
} else if (stripPrefix(text, BUILTIN_TYPE_NAME_FLOAT)) {
608+
} else if (text.consume_front(BUILTIN_TYPE_NAME_FLOAT)) {
618609
Buffer << 'f' << text << '_';
619-
} else if (stripPrefix(text, BUILTIN_TYPE_NAME_VEC)) {
610+
} else if (text.consume_front(BUILTIN_TYPE_NAME_VEC)) {
620611
auto split = text.split('x');
621612
if (split.second == "RawPointer") {
622613
Buffer << 'p';
623-
} else if (stripPrefix(split.second, "Float")) {
614+
} else if (split.second.consume_front("Float")) {
624615
Buffer << 'f' << split.second << '_';
625-
} else if (stripPrefix(split.second, "Int")) {
616+
} else if (split.second.consume_front("Int")) {
626617
Buffer << 'i' << split.second << '_';
627618
} else {
628619
unreachable("unexpected builtin vector type");

0 commit comments

Comments
 (0)