Optimizations:
- ringbuffer: optimize Len(), IsEmpty(), Discard(), Clear() methods with
branchless arithmetic and simplified logic
- fec: fix memory leak in shardHeap.Pop() by setting element to nil before
truncating slice, preventing GC from holding stale references
- timedsched: fix memory leak in timedFuncHeap.Pop() with same nil-before-truncate
pattern; optimize prepend() using slice swap instead of append
- autotune: add sortCache field to Autotuner to reuse slice allocation in
FindPeriod(), avoiding repeated allocations during period detection
- snmp: replace fmt.Sprint with strconv.FormatUint for better performance
in Copy() and Reset() methods
- entropy: remove defer overhead in rngAES.Read() and rngChacha8.Read()
hot paths for reduced function call cost
- bufferpool: pre-allocate ErrBufferPoolSizeExceeded error; reset slice
length on Put() to allow proper reuse
- sess: remove defer overhead in 6 setter methods (SetWriteDelay,
SetWindowSize, SetStreamMode, SetACKNoDelay, SetDUP, SetNoDelay)
These changes reduce memory allocations, fix potential memory leaks in
heap-based data structures, and eliminate defer overhead in frequently
called methods.
- Replace atomic.Pointer[func([]byte)] with atomic.Value for OOB callback storage to improve compatibility.
- Rename SetCallbackForOOB to SetOOBHandler and GetMaxSizeForOOB to GetOOBMaxSize for clearer, consistent API naming.
- Add locking in SendOOB to ensure thread safety during OOB packet construction.
- Update related test cases in sess_test.go to use the new interface names.
- Revise comments and documentation for better clarity and maintainability.
user takes care of the nil handler
use 0xffffffff as the seqid of OOB
return error on nil handler
fix race in test
shorten test data size
add more test on OOB
enhance Error test
allow nil from sender side
add OOBPackets in snmp
use dummy handler instead of resetting the atomic.Value
add test for dummy handler
remove a comment
formalize callback function prototype
use const
rename to expose
Add comments to clarify KCP input and FEC decoding order for FEC packets.
fix test
comments
add TestOOB_OneSideHandler