go count_generic 源码

2022-07-15 浏览 (869)

golang count_generic 代码

文件路径:/src/internal/bytealg/count_generic.go

// Copyright 2018 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.

//go:build !amd64 && !arm && !arm64 && !ppc64le && !ppc64 && !riscv64 && !s390x

package bytealg

func Count(b []byte, c byte) int {
	n := 0
	for _, x := range b {
		if x == c {
			n++
		}
	}
	return n
}

func CountString(s string, c byte) int {
	n := 0
	for i := 0; i < len(s); i++ {
		if s[i] == c {
			n++
		}
	}
	return n
}

相关信息

go 源码目录

相关文章

go bytealg 源码

go compare_generic 源码

go compare_native 源码

go count_native 源码

go equal_generic 源码

go equal_native 源码

go index_amd64 源码

go index_arm64 源码

go index_generic 源码

go index_native 源码

  • 所属分类: 后端技术
  • 本文标签: golang
  • 版权声明: 本文链接 https://seaxiang.com/blog/34cec592befd456fb504d2c6e6331376