tidb math 源码

  • 2022-09-19
  • 浏览 (299)

tidb math 代码

文件路径:/br/pkg/utils/math.go

// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.

package utils

// NextPowerOfTwo returns the smallest power of two greater than or equal to `i`
// Caller should guarantee that i > 0 and the return value is not overflow.
func NextPowerOfTwo(i int64) int64 {
	if i&(i-1) == 0 {
		return i
	}
	i *= 2
	for i&(i-1) != 0 {
		i &= i - 1
	}
	return i
}

相关信息

tidb 源码目录

相关文章

tidb backoff 源码

tidb db 源码

tidb dyn_pprof_other 源码

tidb dyn_pprof_unix 源码

tidb env 源码

tidb json 源码

tidb key 源码

tidb misc 源码

tidb permission 源码

tidb pprof 源码

0  赞