forked from TrueCloudLab/frostfs-node
[#1671] Use max builtin where possible
gopatcH: ``` @@ var d, a expression @@ -if d < a { - d = a -} -return d +return max(d, a) @@ var d, a expression @@ -if d <= a { - d = a -} -return d +return max(d, a) ``` Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
bcc84c85a0
commit
d66bffb191
2 changed files with 5 additions and 20 deletions
|
@ -37,10 +37,7 @@ func (x *Config) Perm() fs.FileMode {
|
||||||
// Returns 0 if the value is not a positive number.
|
// Returns 0 if the value is not a positive number.
|
||||||
func (x *Config) MaxBatchDelay() time.Duration {
|
func (x *Config) MaxBatchDelay() time.Duration {
|
||||||
d := config.DurationSafe((*config.Config)(x), "max_batch_delay")
|
d := config.DurationSafe((*config.Config)(x), "max_batch_delay")
|
||||||
if d < 0 {
|
return max(d, 0)
|
||||||
d = 0
|
|
||||||
}
|
|
||||||
return d
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxBatchSize returns the value of "max_batch_size" config parameter.
|
// MaxBatchSize returns the value of "max_batch_size" config parameter.
|
||||||
|
@ -48,10 +45,7 @@ func (x *Config) MaxBatchDelay() time.Duration {
|
||||||
// Returns 0 if the value is not a positive number.
|
// Returns 0 if the value is not a positive number.
|
||||||
func (x *Config) MaxBatchSize() int {
|
func (x *Config) MaxBatchSize() int {
|
||||||
s := int(config.IntSafe((*config.Config)(x), "max_batch_size"))
|
s := int(config.IntSafe((*config.Config)(x), "max_batch_size"))
|
||||||
if s < 0 {
|
return max(s, 0)
|
||||||
s = 0
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NoSync returns the value of "no_sync" config parameter.
|
// NoSync returns the value of "no_sync" config parameter.
|
||||||
|
@ -66,8 +60,5 @@ func (x *Config) NoSync() bool {
|
||||||
// Returns 0 if the value is not a positive number.
|
// Returns 0 if the value is not a positive number.
|
||||||
func (x *Config) PageSize() int {
|
func (x *Config) PageSize() int {
|
||||||
s := int(config.SizeInBytesSafe((*config.Config)(x), "page_size"))
|
s := int(config.SizeInBytesSafe((*config.Config)(x), "page_size"))
|
||||||
if s < 0 {
|
return max(s, 0)
|
||||||
s = 0
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,10 +52,7 @@ func (x *Config) NoSync() bool {
|
||||||
// Returns 0 if the value is not a positive number.
|
// Returns 0 if the value is not a positive number.
|
||||||
func (x *Config) MaxBatchDelay() time.Duration {
|
func (x *Config) MaxBatchDelay() time.Duration {
|
||||||
d := config.DurationSafe((*config.Config)(x), "max_batch_delay")
|
d := config.DurationSafe((*config.Config)(x), "max_batch_delay")
|
||||||
if d <= 0 {
|
return max(d, 0)
|
||||||
d = 0
|
|
||||||
}
|
|
||||||
return d
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxBatchSize returns the value of "max_batch_size" config parameter.
|
// MaxBatchSize returns the value of "max_batch_size" config parameter.
|
||||||
|
@ -63,8 +60,5 @@ func (x *Config) MaxBatchDelay() time.Duration {
|
||||||
// Returns 0 if the value is not a positive number.
|
// Returns 0 if the value is not a positive number.
|
||||||
func (x *Config) MaxBatchSize() int {
|
func (x *Config) MaxBatchSize() int {
|
||||||
s := int(config.IntSafe((*config.Config)(x), "max_batch_size"))
|
s := int(config.IntSafe((*config.Config)(x), "max_batch_size"))
|
||||||
if s <= 0 {
|
return max(s, 0)
|
||||||
s = 0
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue