Tags: enetx/g
Tags
refactor(print): replace .type/.debug/.wrap modifiers with format spe…
…c verbs
- Add print_fmt.go with Rust-style format mini-language ({:x}, {:>10.2}, {:+05}, etc.)
- Replace .type with {:T}, .debug with {:?}, .wrap with {:w} verb
- Support alignment (<, >, ^), fill, sign (+, -, space), zero-pad, width, precision
- Support verbs: x/X (hex), o (octal), b (binary), e/E (exponential), ? (#? pretty), T, p, w
feat(option): add Filter, Or, OrElse, IsSomeAnd and mutating methods - Add Filter for conditional value filtering - Add Or/OrElse for providing fallback Options - Add IsSomeAnd to check value against predicate - Add Insert, GetOrInsert(+With) for mutable value management - Add Take and Replace for value extraction/swap - Add OkOr/OkOrElse to convert Option to Result - Add FromPtr and Ptr for pointer conversions
feat(hash,bytes,string): add HMAC, raw digests, Hex, and Base64 variants - Add Bytes.Hex() for hex encoding raw bytes - Refactor bytesHasher → rawHasher to separate digest from hex encoding - Add *Raw() variants for MD5/SHA1/SHA256/SHA512 returning raw digests - Add HMACSHA256/HMACSHA512 (hex) and HMACSHA256Raw/HMACSHA512Raw for Bytes and String - Add Base64Raw, Base64URL, Base64RawURL encode/decode variants to String
feat(print): add {wrap} modifier to Errorf for error chain support
Errorf now supports a {wrap} modifier that simultaneously formats an
error value into the message and wraps it in the returned error,
enabling errors.Is / errors.As to traverse the chain.
Supported forms:
{.wrap} — auto-index
{1.wrap} — positional
{name.wrap} — named
multiple {wrap} references wrap multiple errors
Add wrappedError type (Unwrap() []error) to errors.go.
Add TestErrorf covering all forms and edge cases.
Add examples/print/ with basic, format, and errorf examples.
perf: optimize deque, heap, map, slice, and string internals - Deque: extract copyToContiguous helper using copy/clear builtins, replace per-element realIndex loops with direct range slices in Iter, Contains, and String; bulk-copy in DequeOf, Clone, Reserve, ShrinkToFit, MakeContiguous, Slice - Heap: switch to heapify for bulk Push (O(n) vs O(n log n)) - Map: build MapOrd via direct append instead of Insert in Ordered() - MapOrd: replace iterator chains with direct loops and pre-allocated slices in Map, Safe, Keys, Values - Slice: remove closure in SubSlice loop condition; two explicit loops - Slice.Iter: use copy instead of SeqSlice.Collect in SeqSlices.Collect - String: cache .Std() conversions outside hot loops in Chunks, Truncate, writePadding; use rand.N + []byte for default Random charset; inline f.Contains/StartsWith/EndsWith as strings.* - f: cache type conversions outside closures in Contains, ContainsAnyChars, StartsWith, EndsWith - Tests: add TestMapOrdKeys, TestMapOrdToMap, TestMapOrdToSafe
perf: reduce allocations across string, collection, and encoding types string: - Lower/Upper/IsLower/IsUpper/IsTitle: Bytes() → BytesUnsafe()/StringUnsafe() - Random: ASCII fast-path with WriteByte, avoid global charset Runes() alloc - ReplaceNth: Builder instead of triple string concatenation - Chunks: ASCII fast-path (zero-copy slicing); Unicode path via utf8.DecodeRuneInString, eliminating []rune alloc and per-chunk String([]rune) alloc - Truncate: ASCII fast-path + single-pass Unicode walk; drop LenRunes()+Runes() double scan - Center: cache s.LenRunes() and pad.LenRunes() (4 scans → 2) - writePadding: ASCII fast-path with WriteByte; non-ASCII via utf8.DecodeRuneInString, eliminating pad.Runes() alloc on every call - Reverse: BytesUnsafe()/StringUnsafe() - Similarity: plain []int for DP table, min() builtins string/hash: BytesUnsafe()/StringUnsafe() for MD5/SHA1/SHA256/SHA512 string/encode: - Base64/JSON: BytesUnsafe() to avoid copy - URL: Grow() pre-allocation - Hex: inline lookup table — zero per-byte allocs (was: strconv.FormatInt per byte) - Binary: inline bit shift — zero per-byte allocs (was: fmt.Sprintf per byte) - Octal: strconv.AppendInt into stack buffer — zero per-rune allocs string/compress: all five writers use BytesUnsafe() instead of io.WriteString (io.WriteString on non-StringWriter falls back to []byte(s) copy) int: Hex/Octal use strconv.FormatInt instead of fmt.Sprintf set/map/map_ordered: simplify NewX size param (drop Slice[Int] unwrap indirection) String() methods: add Grow() pre-allocation to Slice, Set, Map, MapOrd, MapSafe, Heap, Deque (n*8 or n*16 estimate reduces realloc churn) slice: Join pre-computes exact size and uses a single strings.Builder, eliminating intermediate []string allocation
PreviousNext