fix: use loop variable instead of global ticker in GenerateFreshName #40
@@ -6,13 +6,11 @@ import (
|
|||||||
"git.maximhutz.com/max/lambda/pkg/set"
|
"git.maximhutz.com/max/lambda/pkg/set"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ticker uint64 = 0
|
|
||||||
|
|
||||||
// GenerateFreshName generates a variable name that is not in the used set.
|
// GenerateFreshName generates a variable name that is not in the used set.
|
||||||
// This function does not mutate the used set.
|
// This function does not mutate the used set.
|
||||||
func GenerateFreshName(used set.Set[string]) string {
|
func GenerateFreshName(used set.Set[string]) string {
|
||||||
for i := uint64(0); ; i++ {
|
for i := uint64(0); ; i++ {
|
||||||
attempt := "_" + string(strconv.AppendUint(nil, ticker, 10))
|
attempt := "_" + string(strconv.AppendUint(nil, i, 10))
|
||||||
|
|
||||||
if !used.Has(attempt) {
|
if !used.Has(attempt) {
|
||||||
return attempt
|
return attempt
|
||||||
|
|||||||
Reference in New Issue
Block a user