Skip to content

Commit 7af4451

Browse files
committed
switch nimgrep to using --gc:orc
1 parent 428f28b commit 7af4451

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

tools/nimgrep.nim

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ proc printOutput(filename: string, output: Output, curCol: var Column) =
621621
iterator searchFile(pattern: Pattern; filename: string;
622622
buffer: string): Output =
623623
var prevMi, curMi: MatchInfo
624-
curMi.lineEnd = 1
624+
prevMi.lineEnd = 1
625625
var i = 0
626626
var matches: array[0..re.MaxSubpatterns-1, string]
627627
for j in 0..high(matches): matches[j] = ""
@@ -634,32 +634,32 @@ iterator searchFile(pattern: Pattern; filename: string;
634634
firstLine: prevMi.lineEnd)
635635
break
636636

637-
let lineBeg = curMi.lineEnd + countLineBreaks(buffer, i, t.first-1)
637+
let lineBeg = prevMi.lineEnd + countLineBreaks(buffer, i, t.first-1)
638638
curMi = (first: t.first,
639639
last: t.last,
640640
lineBeg: lineBeg,
641641
lineEnd: lineBeg + countLineBreaks(buffer, t.first, t.last),
642642
match: buffer.substr(t.first, t.last))
643643
if prevMi.lineBeg == 0: # no prev. match, so no prev. block to finalize
644-
yield Output(kind: BlockFirstMatch,
645-
pre: getSubLinesBefore(buffer, curMi),
646-
match: curMi)
644+
let pre = getSubLinesBefore(buffer, curMi)
645+
prevMi = curMi
646+
yield Output(kind: BlockFirstMatch, pre: pre, match: move(curMi))
647647
else:
648648
let nLinesBetween = curMi.lineBeg - prevMi.lineEnd
649649
if nLinesBetween <= linesAfter + linesBefore + 1: # print as 1 block
650-
yield Output(kind: BlockNextMatch,
651-
pre: getSubLinesBetween(buffer, prevMi, curMi),
652-
match: curMi)
650+
let pre = getSubLinesBetween(buffer, prevMi, curMi)
651+
prevMi = curMi
652+
yield Output(kind: BlockNextMatch, pre: pre, match: move(curMi))
653653
else: # finalize previous block and then print next block
654-
yield Output(kind: BlockEnd,
655-
blockEnding: getSubLinesAfter(buffer, prevMi),
654+
let after = getSubLinesAfter(buffer, prevMi)
655+
yield Output(kind: BlockEnd, blockEnding: after,
656656
firstLine: prevMi.lineEnd)
657+
let pre = getSubLinesBefore(buffer, curMi)
658+
prevMi = curMi
657659
yield Output(kind: BlockFirstMatch,
658-
pre: getSubLinesBefore(buffer, curMi),
659-
match: curMi)
660-
660+
pre: pre,
661+
match: move(curMi))
661662
i = t.last+1
662-
prevMi = curMi
663663

664664
func detectBin(buffer: string): bool =
665665
for i in 0 ..< min(1024, buffer.len):
@@ -779,7 +779,7 @@ iterator processFile(searchOptC: SearchOptComp[Pattern], filename: string,
779779
reason = "contains a forbidden match"
780780

781781
if reject:
782-
yield Output(kind: Rejected, reason: reason)
782+
yield Output(kind: Rejected, reason: move(reason))
783783
else:
784784
var found = false
785785
var cnt = 0
@@ -793,7 +793,7 @@ iterator processFile(searchOptC: SearchOptComp[Pattern], filename: string,
793793
if optCount in options and cnt > 0:
794794
yield Output(kind: JustCount, matches: cnt)
795795
if yieldContents and found and optCount notin options:
796-
yield Output(kind: FileContents, buffer: buffer)
796+
yield Output(kind: FileContents, buffer: move(buffer))
797797

798798
proc hasRightFileName(path: string, walkOptC: WalkOptComp[Pattern]): bool =
799799
let filename = path.lastPathPart

tools/nimgrep.nim.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# using markandsweep because of bug https://github.com/nim-lang/Nim/issues/14138
2-
--threads:on --gc:markandsweep
2+
--threads:on --gc:orc

0 commit comments

Comments
 (0)