fastops

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package fastops CPU feature detection. Currently all detection functions return false — no actual SIMD intrinsics are used. This is scaffolding for future platform-specific assembly (.s files with AVX2/NEON instructions).

Package fastops provides performance-optimized string operations using manual loop unrolling (processing 16 bytes per iteration). These 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.

NOTE: Despite historical naming, this package contains NO actual SIMD intrinsics (no AVX2, AVX-512, or NEON assembly). All functions are pure Go scalar implementations with manual loop unrolling. The Dispatcher and CPU feature detection exist as scaffolding for future platform-specific assembly.

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 unrolled scalar 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 unrolled scalar 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. Currently all fields are always false — no real SIMD detection is implemented.

func Detect

func Detect() CPUFeatures

Detect returns CPU SIMD capabilities

type Dispatcher

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

Dispatcher selects optimal implementation. Currently always dispatches to scalar — no real SIMD paths exist. The dispatch structure is scaffolding for future platform-specific assembly.

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher creates dispatcher (currently always scalar).

func (*Dispatcher) EntropyFilter

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

EntropyFilter dispatches to scalar implementation. TODO: Add real AVX2/NEON assembly in entropy_amd64.s / entropy_arm64.s

Jump to

Keyboard shortcuts

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