mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[test-extras] rewrite strip-string to avoid repeat string-append
this is marginally more efficient, by keeping a list of (shared) substrings, and only concatenating them when returning the stripped string.
This commit is contained in:
parent
b05c57a948
commit
ff8c5725cd
@ -61,14 +61,14 @@
|
||||
render)))
|
||||
|
||||
(define (strip-string s1 s2)
|
||||
(let loop ((str s1))
|
||||
(let loop ((str s1)
|
||||
(res '()))
|
||||
(let ((startpos (string-contains str (format #f "<~a" s2)))
|
||||
(endpos (string-contains str (format #f "</~a>" s2))))
|
||||
(if (and startpos endpos)
|
||||
(loop (string-append
|
||||
(string-take str startpos)
|
||||
(string-drop str (+ endpos (string-length s2) 3))))
|
||||
str))))
|
||||
(loop (substring str (+ endpos (string-length s2) 3))
|
||||
(cons (substring str 0 startpos) res))
|
||||
(string-concatenate-reverse (cons str res))))))
|
||||
|
||||
(export gnc:options->sxml)
|
||||
(define* (gnc:options->sxml uuid options prefix test-title #:key strip-tag)
|
||||
|
Loading…
Reference in New Issue
Block a user