commit 5a8b9329bd1669160a67f058dfdd22948b0a8c6f
parent 6caa3c31428d06d4c64d5dadcb58bb13a7cdf939
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Thu, 17 Nov 2022 12:45:22 -0500
simplify code
Diffstat:
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/cmd/art/main.go b/cmd/art/main.go
@@ -138,22 +138,19 @@ func getClassName(idx int) string {
const lastRune = 'z'
out := []rune{firstRune}
for i := idx; i > 0; i-- {
- out[0]++
// 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".
- if out[0] > lastRune {
- found := false
- for i := range out {
- if out[i] < lastRune {
- found = true
- out[i]++
- break
- }
- out[i] = firstRune
- }
- if !found {
- out = append(out, firstRune)
+ found := false
+ for i := range out {
+ if out[i] < lastRune {
+ found = true
+ out[i]++
+ break
}
+ out[i] = firstRune
+ }
+ if !found {
+ out = append(out, firstRune)
}
}
// Reverse slice