]> gitweb.factorcode.org Git - factor.git/commitdiff
Revert "xmode.marker: faster update-match-group"
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 10 Aug 2022 04:19:24 +0000 (21:19 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 10 Aug 2022 04:19:24 +0000 (21:19 -0700)
This reverts commit c489cb3bd4056bf72c43052db578d52bdbc62d53.

basis/xmode/marker/marker.factor

index 2b09ffdd5536b4bb1aa2dc3a26eeb839378a9697..32fae3c3245f06b1b39eddd9a2e12a10fd6cf45a 100644 (file)
@@ -110,13 +110,11 @@ M: regexp text-matches?
 : nth-match ( match regexp n -- slice/f )
     match-group-regexp [ skip-first-match ] [ first-match ] bi* ;
 
-:: update-match-group ( str match regexp n -- str' )
-    n H{ } [ 1 + CHAR: $ swap "" 2sequence ] cache :> x
-    x str subseq? [
-        x match "" like regexp n nth-match str replace
-    ] [ str ] if ;
+: update-match-group ( str match regexp n -- str' )
+    [ nth-match ] [ CHAR: 1 + "$%c" sprintf ] bi swap replace ;
 
 : update-match-groups ( str match regexp -- str' )
+    [ >string ] dip
     dup #match-groups [ update-match-group ] 2with each-integer ;
 
 GENERIC: fixup-end ( match regexp end -- end' )