dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit a09761d6846790f59b60c66d1efa721fb5573514
parent a78232a77977bed00b0678ddc97353fa73342d81
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Thu, 17 Nov 2022 12:57:46 -0500

simplify code

Diffstat:
Mcmd/art/main.go | 10+++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/cmd/art/main.go b/cmd/art/main.go @@ -138,21 +138,17 @@ func getClassName(idx int) string { const lastRune = 'z' out := []rune{firstRune} outLoop: - for i := idx; i > 0; i-- { + for counter := idx; counter > 0; counter-- { // If first letter reached "z", increment the next one which is not yet at "z" // If we did not find a suitable letter to increment, let's add a new one in the array, and reset all to "a". - for i := range out { + for i := len(out) - 1; i >= 0; i-- { if out[i] < lastRune { out[i]++ continue outLoop } out[i] = firstRune } - out = append(out, firstRune) - } - // Reverse slice - for i, j := 0, len(out)-1; i < j; i, j = i+1, j-1 { - out[i], out[j] = out[j], out[i] + out = append([]rune{firstRune}, out...) } return string(out) }