Skip to content

Replace monomorphic buffer functions with generic#9

Merged
hayabusa-cloud merged 2 commits into
mainfrom
refactor
Feb 17, 2026
Merged

Replace monomorphic buffer functions with generic#9
hayabusa-cloud merged 2 commits into
mainfrom
refactor

Conversation

@hayabusa-cloud
Copy link
Copy Markdown
Owner

Summary

Unify 36 type-specific buffer functions into 3 generics using the existing BufferType constraint.

Changes

  • Bump Go 1.26+
  • Replace 12 IoVecFrom*Buffers with IoVecFrom[T BufferType]
  • Replace 12 *ArrayFromSlice with ArrayFromSlice[T BufferType]
  • Replace 12 SliceOf*Array with SliceOfArray[T BufferType]
  • Consolidate tests into subtest loops covering all 12 buffer tiers

Test plan

  • go test -count=1 -race ./... passes
  • go vet ./... clean

Copilot AI review requested due to automatic review settings February 17, 2026 04:20
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the iobuf package to replace 36 type-specific buffer functions with 3 generic implementations using Go generics and the existing BufferType constraint. The refactoring significantly reduces code duplication while maintaining full test coverage and functionality.

Changes:

  • Consolidated 12 IoVecFrom*Buffers functions into a single generic IoVecFrom[T BufferType] function
  • Consolidated 12 *ArrayFromSlice functions into a single generic ArrayFromSlice[T BufferType] function
  • Consolidated 12 SliceOf*Array functions into a single generic SliceOfArray[T BufferType] function
  • Updated Go version requirement from 1.25 to 1.26 (throughout all documentation, CI, and module files)
  • Modernized loop syntax from for i := range len(slice) to for i := range slice
  • Changed BoundedPoolItem from interface{} to any (type alias)
  • Updated all tests and benchmarks to use the new generic functions

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
go.mod Bumped Go version to 1.26 and updated dependencies to v0.3.3 and v0.1.5
go.sum Updated checksums for new dependency versions
iovec.go Replaced 12 monomorphic IoVecFrom functions with single generic implementation using unsafe.Sizeof
iovec_test.go Consolidated 12 separate test functions into one unified TestIoVecFrom with subtests for all buffer types
buffers.go Replaced 24 monomorphic array conversion functions with 2 generic implementations
buffers_test.go Consolidated tests into unified TestArrayFromSlice and TestSliceOfArray with subtests, simplified panic tests
bounded_pool.go Changed BoundedPoolItem from interface{} to any type alias with updated documentation
benchmark_test.go Updated benchmarks to use generic functions and modernized loop syntax
README.md Updated Go version requirement to 1.26
README.*.md Updated Go version requirement to 1.26 in all language variants
.github/workflows/ci.yml Updated CI to use Go 1.26.x

@hayabusa-cloud hayabusa-cloud merged commit c54d37a into main Feb 17, 2026
17 checks passed
@hayabusa-cloud hayabusa-cloud deleted the refactor branch February 17, 2026 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants