Skip to content

Commit

Permalink
perf: use bc-string
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Aug 23, 2021
1 parent cda1ae5 commit 63686fb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ importPaths "./src/native"
dependency "automem" version="~>0.6.6"
preGenerateCommands "git submodule update --init" # despacer download
dependency "despacer" path="./src/native/despacer/bindings/d"
dependency "bc-string" version="1.2.2"

configuration "executable" {
targetType "executable"
Expand Down
1 change: 1 addition & 0 deletions dub.selections.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"fileVersion": 1,
"versions": {
"automem": "0.6.7",
"bc-string": "1.2.2",
"despacer": {"path":"src/native/despacer/bindings/d"},
"test_allocator": "0.3.3",
"unit-threaded": "2.0.3"
Expand Down
5 changes: 3 additions & 2 deletions src/native/lib.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module minijson.lib;

import std : ctRegex, matchAll, matchFirst;
import bc.string: String;

import despacer.simd_check : supports_sse4_1, supports_avx2;

Expand All @@ -22,7 +23,7 @@ string minifyString(in string jsonString, in bool hasComment = false) @trusted
auto in_string = false;
auto in_multiline_comment = false;
auto in_singleline_comment = false;
string result;
String result;
size_t from = 0;
auto rightContext = "";

Expand Down Expand Up @@ -99,7 +100,7 @@ string minifyString(in string jsonString, in bool hasComment = false) @trusted
match.popFront();
}
result ~= rightContext;
return result;
return cast (string) result;
}

private bool hasNoSlashOrEvenNumberOfSlashes(in string leftContextSubstr) @safe @nogc
Expand Down

0 comments on commit 63686fb

Please sign in to comment.