This is an automated email from the ASF dual-hosted git repository.
chia7712 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-k8shim.git
The following commit(s) were added to refs/heads/master by this push:
new 6deff8e9 [YUNIKORN-2335] Use go standard library min and max functions
(#772)
6deff8e9 is described below
commit 6deff8e98112acda72131ab828f1f4a544c38290
Author: geordie <[email protected]>
AuthorDate: Thu Feb 1 01:19:03 2024 +0800
[YUNIKORN-2335] Use go standard library min and max functions (#772)
Closes: #772
Signed-off-by: Chia-Ping Tsai <[email protected]>
---
pkg/cache/external/scheduler_cache.go | 7 +------
pkg/dispatcher/dispatcher.go | 6 ++----
pkg/log/logger.go | 4 +---
3 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/pkg/cache/external/scheduler_cache.go
b/pkg/cache/external/scheduler_cache.go
index 866ed76e..a81977da 100644
--- a/pkg/cache/external/scheduler_cache.go
+++ b/pkg/cache/external/scheduler_cache.go
@@ -608,12 +608,7 @@ func (cache *SchedulerCache) addSchedulingTask(taskID
string) {
}
func (filter *taskBloomFilter) addTask(taskID string) {
- limit := len(taskID)
-
- if limit > 4 {
- limit = 4
- }
-
+ limit := min(4, len(taskID))
for i := 0; i < limit; i++ {
filter.data[i][taskID[i]] = true
}
diff --git a/pkg/dispatcher/dispatcher.go b/pkg/dispatcher/dispatcher.go
index 7bfd17cf..f2727143 100644
--- a/pkg/dispatcher/dispatcher.go
+++ b/pkg/dispatcher/dispatcher.go
@@ -69,10 +69,8 @@ func initDispatcher() {
}
dispatcher.setRunning(false)
DispatchTimeout = conf.GetSchedulerConf().DispatchTimeout
- AsyncDispatchLimit = int32(eventChannelCapacity / 10)
- if AsyncDispatchLimit < 10000 {
- AsyncDispatchLimit = 10000
- }
+ AsyncDispatchLimit = max(10000, int32(eventChannelCapacity/10))
+
log.Log(log.ShimDispatcher).Info("Init dispatcher",
zap.Int("EventChannelCapacity", eventChannelCapacity),
zap.Int32("AsyncDispatchLimit", AsyncDispatchLimit),
diff --git a/pkg/log/logger.go b/pkg/log/logger.go
index 5897c0c7..96609847 100644
--- a/pkg/log/logger.go
+++ b/pkg/log/logger.go
@@ -266,9 +266,7 @@ func initLoggingConfig(config map[string]string) {
// compute the finest log level necessary to allow all loggers to
succeed
minLevel := zapcore.InvalidLevel - 1
for _, v := range levelMap {
- if minLevel > v {
- minLevel = v
- }
+ minLevel = min(v, minLevel)
}
// create each configured logger and initialize the overall
configuration
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]