# README
x-sync - experimental x-sync utilities
x-sync is likely not what you're looking for. This project exists to mainly have a reference for things one may think are great optimizations of standard go things but did not turn out to be the case.
General Notes
- the built-in
append
function is really fast as it is but if there's a need for controlling the slice scaling process, this package has anAppendScale
function which may be useful - working with sync.Pool is a very specific task, usually unique to each project's needs, however if there's a need for a generic and convenient sync.Pool that doesn't need boilerplate, take at look at this package's Pool type and the NewStringBuilderPool convenience function
- some benchmarks have been added and they basically demonstrate that the
standard Go
append
function is really tough to beat, though admittedly the case scenario being benchmarked may not be the best implementation for comparative benchmarking purposes - don't optimize too early in the development cycle, just get things done until it's obviously working and then consider this package for testing really simply optimizations before delving into the more appropriate project-specific minimum viable product performance tuning
Installation
> go get github.com/go-corelibs/x-sync@latest
Go-CoreLibs
Go-CoreLibs is a repository of shared code between the Go-Curses and Go-Enjin projects.
License
Copyright 2024 The Go-CoreLibs Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use file except in compliance with the License.
You may obtain a copy of the license at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
# Functions
Append is an experiment in appending to slices without using the standard Go append function.
AppendScaled is like Append but includes the scale argument for specifying the cap growth multiplier.
NewPool constructs a new Pool instance with the given scale, maker function and the two optional PoolHookFn functions
Passing nil for the hooks is valid, for example to create a Pool without a getter hook but with a setter, pass a nil for the first hooks argument
Scale values less than or equal to zero are clamped to a minimum scale of 1.
NewStringBuilderPool is a convenience wrapper around NewPool, configured for the *strings.Builder type (all Pool values must be pointers), and includes both getter and setter PoolHookFn implementations.
# Interfaces
Pool is a convenience interface for working with the standard sync.Pool.
# Type aliases
PoolHookFn is the function signature used with NewPool.