fix(repeating_group): add Reset() method (closes #758) - #775
Open
caiyi0616 wants to merge 1 commit into
Open
Conversation
Implement RepeatingGroup.Reset() to clear all groups without reallocating the template or struct. This addresses issue quickfixgo#758, where repeated message parsing required new RepeatingGroup instances for each parse, causing unnecessary allocations in high-throughput FIX message processing scenarios. Changes: - Add RepeatingGroup.Reset() that clears groups slice (keeps capacity) - Add test_repeating_group_reset.go covering Reset() behavior and multi-cycle reuse without reallocation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
RepeatingGroup.Reset()method to clear all groups from aRepeatingGroupinstance, allowing reuse without reallocating the underlying template and struct. This addresses issue #758.Motivation
In high-throughput FIX message processing scenarios, each incoming message may contain a repeating group with a variable number of entries. Previously, parsing required allocating a new
RepeatingGroupinstance for each parse, causing unnecessary allocations and GC pressure. WithReset(), callers can reuse the same instance across multiple message parses, reducing allocations in hot paths.Changes
repeating_group.gorepeating_group_test.goAdded comprehensive tests:
TestRepeatingGroup_Reset: Verifies that Reset() clears all groups and keeps capacityTestRepeatingGroup_ResetMultipleCycles: Verifies instance reuse across multiple parse cycles without reallocationVerification
go test ./...)go test -run "Reset" -vCloses #758