From ad51c5e00a0d000fb108d9ca7b376737a5772f2c Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Sun, 7 Apr 2019 10:23:55 +0800 Subject: [PATCH] [report] rewrite gnc:report-template-make-unique-name --- gnucash/report/report-system/report.scm | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/gnucash/report/report-system/report.scm b/gnucash/report/report-system/report.scm index 6e300c28a1..30874460c8 100644 --- a/gnucash/report/report-system/report.scm +++ b/gnucash/report/report-system/report.scm @@ -504,15 +504,12 @@ not found."))) ;; If this string already exists as a custom template name, a ;; number will be appended to it. (define (gnc:report-template-make-unique-name new-name) - (let* ((unique-name new-name) - (counter 0) - (unique? (gnc:report-template-has-unique-name? #f unique-name))) - (while (not unique?) - (begin - (set! counter (+ counter 1)) - (set! unique-name (string-append new-name (number->string counter))) - (set! unique? (gnc:report-template-has-unique-name? #f unique-name)))) - unique-name)) + (let loop ((name new-name) + (counter 1)) + (if (gnc:report-template-has-unique-name? #f name) + name + (loop (string-append new-name (number->string counter)) + (1+ counter))))) ;; Load and save functions