mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-09 22:52:58 +03:00
[PR #331] [MERGED] fix: Fixes and performance improvements in utils package #869
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?
📋 Pull Request Information
Original PR: https://github.com/pocket-id/pocket-id/pull/331
Author: @ItalyPaleAle
Created: 3/14/2025
Status: ✅ Merged
Merged: 3/15/2025
Merged by: @kmendell
Base:
main← Head:utils-fixes-perf📝 Commits (6)
95efaadfix: Fixes and performance improvements in utils package8e78301Merge branch 'main' into utils-fixes-perf874c75dRemove benchmarks29a8edcMerge branch 'main' of https://github.com/pocket-id/pocket-id into utils-fixes-perf7229b04Run unit tests during CIc5373beFix CI📊 Changes
6 files changed (+260 additions, -28 deletions)
View changed files
📝
.github/workflows/e2e-tests.yml(+23 -0)📝
backend/internal/utils/file_util.go(+5 -3)➕
backend/internal/utils/file_util_test.go(+73 -0)📝
backend/internal/utils/image/profile_picture.go(+1 -1)📝
backend/internal/utils/string_util.go(+53 -24)➕
backend/internal/utils/string_util_test.go(+105 -0)📄 Description
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
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.