Skip to content

sqf: Add optimization to bypass single use vars - #1288

Draft
PabstMirror wants to merge 1 commit into
mainfrom
optimze-reduceVars
Draft

sqf: Add optimization to bypass single use vars#1288
PabstMirror wants to merge 1 commit into
mainfrom
optimze-reduceVars

Conversation

@PabstMirror

Copy link
Copy Markdown
Collaborator

Simplify code by bypassing local var storage and gluing commands together

private _pos = getPos player;
_pos vectorAdd offset
// simplify to just
(getPos player) vectorAdd offset

Assumptions:

  • _pos can't have any upstream effects because it is private
  • nothing below is using _pos
  • nothing below can call code that would be using _pos

Test

private _a = diag_tickTime;
x = _a + 5;

private _b = 6;
private _c = _b + 7;

private _d = "test";
_d + "ing"
Original 0.00180925 ms
callNular diag_ticktime;
assignToLocal _a;

getVariable _a;
push 5
callOperator +;
assignTo x;

push 6
assignToLocal _b;

getVariable _b;
push 7
callOperator +;
assignToLocal _c;

push ""test""
assignToLocal _d;

getVariable _d;
push ""ing""
callOperator +;
Optimized 0.0013578 ms
callNular diag_ticktime;
push 5
callOperator +;
assignTo x;

push 6
push 7
callOperator +;
assignToLocal _c;

push ""test""
push ""ing""
callOperator +;

@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.00000% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.6%. Comparing base (c61e0c0) to head (2ef9df2).

Files with missing lines Patch % Lines
libs/sqf/src/compiler/optimizer/statements.rs 84.8% 18 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
libs/sqf/src/compiler/optimizer/mod.rs 83.7% <100.0%> (ø)
libs/sqf/src/compiler/optimizer/statements.rs 84.8% <84.8%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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