MCPcopy Create free account
hub / github.com/codechenx/FastTableViewer / countRuneFast

Function countRuneFast

sepDector.go:58–66  ·  view source on GitHub ↗

Optimized rune counter - much faster than strings.Count for single runes

(s string, r rune)

Source from the content-addressed store, hash-verified

56
57// Optimized rune counter - much faster than strings.Count for single runes
58func countRuneFast(s string, r rune) int {
59 count := 0
60 for _, c := range s {
61 if c == r {
62 count++
63 }
64 }
65 return count
66}
67
68// Analyze all potential separators when common ones don't work
69func (sd *sepDetecor) detectBestSeparator(lines []string) rune {

Callers 4

isValidSeparatorMethod · 0.85
detectBestSeparatorMethod · 0.85
TestCountRuneFastFunction · 0.85
BenchmarkCountRuneFastFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestCountRuneFastFunction · 0.68
BenchmarkCountRuneFastFunction · 0.68