Skip to content

Commit 914ee42

Browse files
committed
refactor: notSlashAndNoSpaceOrBreak
1 parent 161e698 commit 914ee42

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/native/lib.d

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ string minifyString(string jsonString, bool hasComment = false) @trusted
8080
{
8181
in_singleline_comment = true;
8282
}
83-
else if (matchFrontHit != "\"" && matchFrontHit.matchFirst(spaceOrBreakRegex).empty())
83+
else if (notSlashAndNoSpaceOrBreak(matchFrontHit))
8484
{
8585
new_str ~= matchFrontHit;
8686
}
@@ -94,7 +94,7 @@ string minifyString(string jsonString, bool hasComment = false) @trusted
9494
in_singleline_comment = false;
9595
}
9696
}
97-
if (!hasComment && matchFrontHit != "\"" && matchFrontHit.matchFirst(spaceOrBreakRegex).empty())
97+
if (!hasComment && notSlashAndNoSpaceOrBreak(matchFrontHit))
9898
{
9999
new_str ~= matchFrontHit;
100100
}
@@ -104,13 +104,18 @@ string minifyString(string jsonString, bool hasComment = false) @trusted
104104
return new_str.array().join("");
105105
}
106106

107-
bool hasNoSlashOrEvenNumberOfSlashes(string leftContext) @safe
107+
private bool hasNoSlashOrEvenNumberOfSlashes(string leftContext) @safe
108108
{
109109
auto leftContextMatch = leftContext.matchFirst(repeatingBackSlashRegex);
110110
// if not matched the hit length will be 0 (== leftContextMatch.empty())
111111
return leftContextMatch.hit().length % 2 == 0;
112112
}
113113

114+
private bool notSlashAndNoSpaceOrBreak(string matchFrontHit)
115+
{
116+
return matchFrontHit != "\"" && matchFrontHit.matchFirst(spaceOrBreakRegex).empty();
117+
}
118+
114119
/**
115120
Minify the given files in place. It minifies the files in parallel.
116121

0 commit comments

Comments
 (0)