Skip to content

Commit

Permalink
remove pointless stringbuilder operations
Browse files Browse the repository at this point in the history
  • Loading branch information
ike709 committed Jan 27, 2025
1 parent 730862b commit 55431e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 7 additions & 0 deletions Content.Tests/DMProject/Tests/Expression/String/raw3.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

//# issue 380

/proc/RunTest()
var/a = @(ZZQ)
asdfZZQ
ASSERT(a == "asdf")
8 changes: 2 additions & 6 deletions DMCompiler/Compiler/DMPreprocessor/DMPreprocessorLexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,7 @@ public Token NextToken(bool ignoreWhitespace = false) {
if (GetCurrent() == complexDelimiter[delimIdx]) delimIdx++;
else delimIdx = 0;

if (delimIdx + 1 == complexDelimiter.Length && c == complexDelimiter[^1]) { // latter check ensures a 1-char delimiter actually matches
TokenTextBuilder.Remove(TokenTextBuilder.Length - delimIdx, complexDelimiter.Length - 1);
if (delimIdx == complexDelimiter.Length && c == complexDelimiter[^1]) { // latter check ensures a 1-char delimiter actually matches
break;
}

Expand All @@ -360,8 +359,6 @@ public Token NextToken(bool ignoreWhitespace = false) {
_compiler.Emit(WarningCode.BadExpression, startLoc,
"Unterminated string delimiter");
}

TokenTextBuilder.Append(complexDelimiter);
} else if (isLong) {
bool nextCharCanTerm = false;

Expand Down Expand Up @@ -395,8 +392,7 @@ public Token NextToken(bool ignoreWhitespace = false) {
}
}

if (isComplex) Advance();
else TokenTextBuilder.Append(c);
if (!isComplex) TokenTextBuilder.Append(c);

if (!HandleLineEnd())
Advance();
Expand Down

0 comments on commit 55431e4

Please sign in to comment.