perf: convert getchildren to querydescendants#56
perf: convert getchildren to querydescendants#56Ramdoys wants to merge 2 commits intosmartbone-org:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR attempts to optimize performance by replacing GetChildren() calls with QueryDescendants() using direct child selectors. The changes target the bone tree construction logic in the main SmartBone module and a pooling function in the ImOverlay debug component.
Changes:
- Replaced
GetChildren()withQueryDescendants("> Bone")in bone tree traversal logic - Attempted to replace
GetChildren()with a filteredQueryDescendants()in ImOverlay pooling - Removed explicit
IsA("Bone")type checks made redundant by QueryDescendants filtering
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/init.luau | Updates AddChildren function to use QueryDescendants for bone hierarchy traversal |
| src-build/init.luau | Mirror of src/init.luau changes in the build output |
| src-build/Dependencies/Debug/ImOverlay/CeiveImOverlay.luau | Attempts to optimize m_Pool function with QueryDescendants filtering |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
|
|
||
| for _, Obj in self.BackFrame:GetChildren() do | ||
| for _, Obj in self.BackFrame:QueryDescendants("> :not(UIListLayout, [Visible = false])") do |
There was a problem hiding this comment.
The QueryDescendants selector is malformed and will not work as intended. The selector "> :not(UIListLayout, [Visible = false])" has multiple issues: (1) :not() cannot contain comma-separated selectors in QueryDescendants, (2) [Visible=false] attempts to filter by the Visible property, but QueryDescendants attribute selectors only work with actual Attributes, not instance properties. The Visible property must be checked in code. Since the filtering logic on lines 126-128 is still present and necessary, this change provides no benefit over the original GetChildren() approach and may actually cause unexpected behavior with the malformed selector.
| for _, Obj in self.BackFrame:QueryDescendants("> :not(UIListLayout, [Visible = false])") do | |
| for _, Obj in self.BackFrame:GetChildren() do |
|
|
||
|
|
||
| for _, Obj in self.BackFrame:GetChildren() do | ||
| for _, Obj in self.BackFrame:QueryDescendants("> :not(UIListLayout, [Visible = false])") do |
There was a problem hiding this comment.
The change to QueryDescendants appears only in the src-build version of this file, but not in the corresponding source file at src/Dependencies/Debug/ImOverlay/CeiveImOverlay.luau (which still uses GetChildren). Since src-build appears to be generated from src through a build process (darklua), these files should be kept in sync. Either the source file should also be updated, or the build output should be regenerated from the unchanged source to maintain consistency.
| for _, Obj in self.BackFrame:QueryDescendants("> :not(UIListLayout, [Visible = false])") do | |
| for _, Obj in self.BackFrame:GetChildren() do |
|
|
||
|
|
||
| for _, Obj in self.BackFrame:GetChildren() do | ||
| for _, Obj in self.BackFrame:QueryDescendants("> :not(UIListLayout, [Visible = false])") do |
There was a problem hiding this comment.
The for loop has lost its indentation. It should be indented with a tab character to match the function's indentation level, similar to the other code in this function (see line 131 which correctly has indentation).
This PR uses QueryDescendant's direct children of to squeeze out more performance.