tidb bytes 源码

2022-09-19 浏览 (686)

tidb bytes 代码

文件路径:/br/pkg/lightning/mydump/bytes.go

/ Copyright 2009 The Go Authors. All rights reserved.
/ Use of this source code is governed by a BSD-style
/ license that can be found in the LICENSE file.

/ Package bytes implements functions for the manipulation of byte slices.
/ It is analogous to the facilities of the strings package.

/ this is copy from `bytes/bytes.go`

package mydump

/ byteSet is a 32-byte value, where each bit represents the presence of a
/ given byte value in the set.
type byteSet [8]uint32

/ makeByteSet creates a set of byte value.
func makeByteSet(chars []byte) (as byteSet) {
	for i := 0; i < len(chars); i++ {
		c := chars[i]
		as[c>>5] |= 1 << uint(c&31)
	}
	return as
}

/ contains reports whether c is inside the set.
func (as *byteSet) contains(c byte) bool {
	return (as[c>>5] & (1 << uint(c&31))) != 0
}

/ IndexAnyByte returns the byte index of the first occurrence in s of any of the byte
/ points in chars. It returns -1 if  there is no code point in common.
func IndexAnyByte(s []byte, as *byteSet) int {
	for i, c := range s {
		if as.contains(c) {
			return i
		}
	}
	return -1
}

相关信息

tidb 源码目录

相关文章

tidb charset_convertor 源码

tidb csv_parser 源码

tidb loader 源码

tidb parquet_parser 源码

tidb parser 源码

tidb parser_generated 源码

tidb reader 源码

tidb region 源码

tidb router 源码

^