✨ Add options to improve performances - #17
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds opt-in performance options to the public parser API (SkipUnknownPayloads, SkipParameterParsing, SkipCommands, SkipTargetEventCodes) plumbed via a new types.Config on the parsing context, re-exports the protocol command/event constants under the photon package so users can build option calls, and tightens reliable-payload length accounting in the command/reliable parsers.
Changes:
- New
Option/Configmachinery (options.go,internal/types/config.go) wired throughNewV16/NewV18/ParseV16/ParseV18andinternal/context.NewContext. - Skip logic added in
internal/command/command.goandinternal/command/reliable/reliable.go, and reliable-payload length passed explicitly (payloadLen) instead of the previousREADED_HEADER_SIZEconstant. - New tests and benchmarks in
parser_test.goexercising the four skip options on dataset 3/1.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
options.go |
Defines Option, DefaultConfig, and the four Skip* option constructors. |
internal/types/config.go |
Introduces the Config struct used by the parsing context. |
types.go |
Adds re-exported aliases and re-declares CommandType/Type constants in the public package. |
parser.go |
NewV16/NewV18/ParseV16/ParseV18 accept ...Option and forward a built Config to the context. |
internal/context/context.go |
Context gains a Config field and NewContext requires it. |
internal/command/command.go |
Honors SkipUnknownPayloads/SkipCommands, emits unknown payloads, and bounds-checks reliable payload length. |
internal/command/reliable/reliable.go |
Replaces READED_HEADER_SIZE with a per-call start/payloadLen, adds SkipParameterParsing/SkipTargetEventCodes shortcuts. |
internal/command/reliable/fragment.go |
Passes the assembled buffer length as payloadLen after reset. |
internal/session/session_test.go |
Updates NewContext call sites to pass types.Config{}. |
parser_test.go |
Adds four Without* tests and two new benchmarks for the skip options. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.