Skip to content

Comments

perf: convert getchildren to querydescendants#56

Open
Ramdoys wants to merge 2 commits intosmartbone-org:mainfrom
Ramdoys:pull-1
Open

perf: convert getchildren to querydescendants#56
Ramdoys wants to merge 2 commits intosmartbone-org:mainfrom
Ramdoys:pull-1

Conversation

@Ramdoys
Copy link
Contributor

@Ramdoys Ramdoys commented Feb 12, 2026

This PR uses QueryDescendant's direct children of to squeeze out more performance.

Copilot AI review requested due to automatic review settings February 12, 2026 23:07
Copy link

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 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() with QueryDescendants("> Bone") in bone tree traversal logic
  • Attempted to replace GetChildren() with a filtered QueryDescendants() 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
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
for _, Obj in self.BackFrame:QueryDescendants("> :not(UIListLayout, [Visible = false])") do
for _, Obj in self.BackFrame:GetChildren() do

Copilot uses AI. Check for mistakes.


for _, Obj in self.BackFrame:GetChildren() do
for _, Obj in self.BackFrame:QueryDescendants("> :not(UIListLayout, [Visible = false])") do
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
for _, Obj in self.BackFrame:QueryDescendants("> :not(UIListLayout, [Visible = false])") do
for _, Obj in self.BackFrame:GetChildren() do

Copilot uses AI. Check for mistakes.


for _, Obj in self.BackFrame:GetChildren() do
for _, Obj in self.BackFrame:QueryDescendants("> :not(UIListLayout, [Visible = false])") do
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
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.

1 participant