Skip to content

Commit 63686fb

Browse files
committed
perf: use bc-string
1 parent cda1ae5 commit 63686fb

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

dub.sdl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ importPaths "./src/native"
1212
dependency "automem" version="~>0.6.6"
1313
preGenerateCommands "git submodule update --init" # despacer download
1414
dependency "despacer" path="./src/native/despacer/bindings/d"
15+
dependency "bc-string" version="1.2.2"
1516

1617
configuration "executable" {
1718
targetType "executable"

dub.selections.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"fileVersion": 1,
33
"versions": {
44
"automem": "0.6.7",
5+
"bc-string": "1.2.2",
56
"despacer": {"path":"src/native/despacer/bindings/d"},
67
"test_allocator": "0.3.3",
78
"unit-threaded": "2.0.3"

src/native/lib.d

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module minijson.lib;
22

33
import std : ctRegex, matchAll, matchFirst;
4+
import bc.string: String;
45

56
import despacer.simd_check : supports_sse4_1, supports_avx2;
67

@@ -22,7 +23,7 @@ string minifyString(in string jsonString, in bool hasComment = false) @trusted
2223
auto in_string = false;
2324
auto in_multiline_comment = false;
2425
auto in_singleline_comment = false;
25-
string result;
26+
String result;
2627
size_t from = 0;
2728
auto rightContext = "";
2829

@@ -99,7 +100,7 @@ string minifyString(in string jsonString, in bool hasComment = false) @trusted
99100
match.popFront();
100101
}
101102
result ~= rightContext;
102-
return result;
103+
return cast (string) result;
103104
}
104105

105106
private bool hasNoSlashOrEvenNumberOfSlashes(in string leftContextSubstr) @safe @nogc

0 commit comments

Comments
 (0)