diff --git a/server/channels/app/notification.go b/server/channels/app/notification.go index 3d45b1d74fb1..854abf8237a8 100644 --- a/server/channels/app/notification.go +++ b/server/channels/app/notification.go @@ -1138,13 +1138,6 @@ func (a *App) getExplicitMentionsAndKeywords(c request.CTX, post *model.Post, ch return mentions, keywords } -func max(a, b int64) int64 { - if a < b { - return b - } - return a -} - func (a *App) userAllowsEmail(c request.CTX, user *model.User, channelMemberNotificationProps model.StringMap, post *model.Post) bool { // if user is a bot account or remote, then we do not send email if user.IsBot || user.IsRemote() { diff --git a/server/channels/app/platform/service.go b/server/channels/app/platform/service.go index ac32eb71ab2b..4ca223189c55 100644 --- a/server/channels/app/platform/service.go +++ b/server/channels/app/platform/service.go @@ -303,7 +303,7 @@ func New(sc ServiceConfig, options ...Option) (*PlatformService, error) { Name: "Status", Size: model.StatusCacheSize, Striped: true, - StripedBuckets: maxInt(runtime.NumCPU()-1, 1), + StripedBuckets: max(runtime.NumCPU()-1, 1), DefaultExpiry: 30 * time.Minute, }) if err != nil { @@ -314,7 +314,7 @@ func New(sc ServiceConfig, options ...Option) (*PlatformService, error) { Name: "Session", Size: model.SessionCacheSize, Striped: true, - StripedBuckets: maxInt(runtime.NumCPU()-1, 1), + StripedBuckets: max(runtime.NumCPU()-1, 1), }) if err != nil { return nil, fmt.Errorf("could not create session cache: %w", err) diff --git a/server/channels/app/platform/utils.go b/server/channels/app/platform/utils.go index c8f48c0495cd..2e7af04bee21 100644 --- a/server/channels/app/platform/utils.go +++ b/server/channels/app/platform/utils.go @@ -14,13 +14,6 @@ func getKeyHash(key string) string { return base64.StdEncoding.EncodeToString(hash.Sum(nil)) } -func maxInt(a, b int) int { - if a > b { - return a - } - return b -} - // allocateCacheTargets is used to fill target value types // for getting items from cache. func allocateCacheTargets[T any](l int) []any { diff --git a/server/channels/store/localcachelayer/layer.go b/server/channels/store/localcachelayer/layer.go index 20e55c0fdd12..1003a01d6103 100644 --- a/server/channels/store/localcachelayer/layer.go +++ b/server/channels/store/localcachelayer/layer.go @@ -152,7 +152,7 @@ func NewLocalCacheLayer(baseStore store.Store, metrics einterfaces.MetricsInterf DefaultExpiry: RoleCacheSec * time.Second, InvalidateClusterEvent: model.ClusterEventInvalidateCacheForRoles, Striped: true, - StripedBuckets: maxInt(runtime.NumCPU()-1, 1), + StripedBuckets: max(runtime.NumCPU()-1, 1), }); err != nil { return } @@ -336,7 +336,7 @@ func NewLocalCacheLayer(baseStore store.Store, metrics einterfaces.MetricsInterf DefaultExpiry: UserProfileByIDSec * time.Second, InvalidateClusterEvent: model.ClusterEventInvalidateCacheForProfileByIds, Striped: true, - StripedBuckets: maxInt(runtime.NumCPU()-1, 1), + StripedBuckets: max(runtime.NumCPU()-1, 1), }); err != nil { return } @@ -394,13 +394,6 @@ func NewLocalCacheLayer(baseStore store.Store, metrics einterfaces.MetricsInterf return } -func maxInt(a, b int) int { - if a > b { - return a - } - return b -} - func (s LocalCacheStore) Reaction() store.ReactionStore { return s.reaction } diff --git a/server/channels/store/sqlstore/shared_channel_store.go b/server/channels/store/sqlstore/shared_channel_store.go index 73d8d2c92da7..e47b03d4e197 100644 --- a/server/channels/store/sqlstore/shared_channel_store.go +++ b/server/channels/store/sqlstore/shared_channel_store.go @@ -818,7 +818,7 @@ func (s SqlSharedChannelStore) UpdateUserLastSyncAt(userID string, channelID str return err } - updateAt := maxInt64(user.UpdateAt, user.LastPictureUpdate) + updateAt := max(user.UpdateAt, user.LastPictureUpdate) query := s.getQueryBuilder(). Update("SharedChannelUsers AS scu"). diff --git a/server/channels/store/sqlstore/utils.go b/server/channels/store/sqlstore/utils.go index 0aa87cb7afd9..6ce0dda45b37 100644 --- a/server/channels/store/sqlstore/utils.go +++ b/server/channels/store/sqlstore/utils.go @@ -192,13 +192,6 @@ func trimInput(input string) string { return input } -func maxInt64(a, b int64) int64 { - if a > b { - return a - } - return b -} - // Adds backtiks to the column name for MySQL, this is required if // the column name is a reserved keyword. // diff --git a/server/public/pluginapi/cluster/mock_plugin_api_test.go b/server/public/pluginapi/cluster/mock_plugin_api_test.go index 5a5487a4ae49..d1f53c95f2f8 100644 --- a/server/public/pluginapi/cluster/mock_plugin_api_test.go +++ b/server/public/pluginapi/cluster/mock_plugin_api_test.go @@ -102,13 +102,6 @@ func (pluginAPI *mockPluginAPI) KVList(page, count int) ([]string, *model.AppErr return keys[start:end], nil } -func min(a, b int) int { - if a < b { - return a - } - return b -} - func (pluginAPI *mockPluginAPI) KVSetWithOptions(key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError) { pluginAPI.lock.Lock() defer pluginAPI.lock.Unlock()