simd

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package simd provides performance-optimized string operations using manual loop unrolling (processing 16 bytes per iteration). Despite the package name, these are NOT hardware SIMD/vector instructions — they are manually unrolled scalar loops that improve performance by reducing branch overhead and enabling better CPU pipelining. The Go compiler may auto-vectorize some patterns, but correctness does not depend on hardware SIMD support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsAny

func ContainsAny(s string, substrs []string) bool

ContainsAny checks if string contains any of the substrings

func ContainsWord

func ContainsWord(s, word string) bool

ContainsWord checks if string contains word (space-delimited)

func FastContains

func FastContains(s, substr string) bool

FastContains checks if string contains substring (optimized for small patterns)

func FastCountBytes

func FastCountBytes(data string, target byte) int

FastCountBytes counts bytes using SIMD-optimized loop

func FastEqual

func FastEqual(a, b string) bool

FastEqual compares strings with early exit

func FastHasANSI

func FastHasANSI(data string) bool

FastHasANSI checks for ANSI sequences using SIMD-friendly loop

func FastLower

func FastLower(s string) string

FastLower ASCII lowercase conversion (optimized with unsafe)

func HasANSI

func HasANSI(data string) bool

HasANSI is an alias for FastHasANSI for backward compatibility

func IsWordChar

func IsWordChar(c byte) bool

IsWordChar checks if byte is a word character

func Process

func Process(data string) string

Process is an alias for StripANSI for backward compatibility

func SplitWords

func SplitWords(input string) []string

SplitWords splits string into words (optimized)

func StripANSI

func StripANSI(input string) string

StripANSI removes ANSI sequences using optimized byte operations

Types

type CPUFeatures

type CPUFeatures struct {
	HasAVX2   bool
	HasAVX512 bool
	HasNEON   bool
}

CPUFeatures holds detected CPU capabilities

func Detect

func Detect() CPUFeatures

Detect returns CPU SIMD capabilities

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

Dispatcher selects optimal SIMD implementation

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher creates SIMD dispatcher

func (*Dispatcher) EntropyFilter

func (d *Dispatcher) EntropyFilter(data []float64) float64

EntropyFilter dispatches to SIMD or scalar

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL