mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-11 07:42:58 +03:00
[PR #331] fix: Fixes and performance improvements in utils package #877
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/pocket-id/pocket-id/pull/331
State: closed
Merged: Yes
GetFileExtensionpanics if the input is an empty stringstring_util.go:GenerateRandomAlphanumericString,CapitalizeFirstLetter,CamelCaseToSnakeCase. In addition to being faster, in some cases a lot (seeBenchmarkGenerateRandomAlphanumericString/128-12where individual execution time is now 94% faster), there are a lot less allocations (and they are mostly constant and not increasing depending on input), which reduces the pressure on the GCBehavior is unchanged, as confirmed by unit tests created before the refactorings.
Benchmark env
goos: darwin
goarch: arm64
pkg: github.com/pocket-id/pocket-id/backend/internal/utils
cpu: Apple M2 Pro
Before
BenchmarkGenerateRandomAlphanumericString
BenchmarkCapitalizeFirstLetter
BenchmarkCamelCaseToSnakeCase
After
BenchmarkGenerateRandomAlphanumericString
BenchmarkCapitalizeFirstLetter
BenchmarkCamelCaseToSnakeCase