perf(info): avoid duplicate desc().child() lookup in _get_channel_info#114
Merged
cboulay merged 1 commit intoJun 16, 2026
Merged
Conversation
_get_channel_info fetched self.desc().child("channels") twice - once for
the empty() guard and again to iterate. Each call is two liblsl FFI calls
(lsl_get_desc + lsl_child) plus an XMLElement allocation. Compute it once
and reuse it. Cold path (metadata read), behavior unchanged.
cboulay
approved these changes
Jun 16, 2026
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.
(PR and content generated with the help of Claude)
What
Compute
self.desc().child("channels")once inStreamInfo._get_channel_infoinstead of twice.Why
The method fetched the same node twice — once for the
.empty()guard and again to start iterating:Each
self.desc().child("channels")is two liblsl FFI calls (lsl_get_desc+lsl_child) plus anXMLElementallocation. Now it's computed once and reused:Impact
Eliminates 2 redundant FFI calls + 1 object allocation per call to
get_channel_labels/get_channel_types/get_channel_units. This is a cold path (metadata read, not streaming), so the runtime impact is small — it's mainly a clarity/cleanliness fix.Behavior
Unchanged. Verified the empty->
Nonebranch and label/type/unit round-trips; existing test suite passes.