-
-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Problem
The three sync modifiers (synccomputesmodifier.ts, syncfixesmodifier.ts, syncvariablesmodifier.ts) have ~80% code duplication, specifically in the Data1D processing logic (lines ~55-118 in each file).
Current Behavior
Each modifier contains nearly identical code for:
- Getting
data1DNamesand checking size - Processing
clearPerSynclogic - Looping through
data1DVectorand extracting x/y values - Proper cleanup of WASM objects (
data1DNamesWrapper,lmpData,data1DVector)
Expected Behavior
Extract the common Data1D processing logic into a shared helper function that can be reused by all three modifiers.
Proposed Solution
Create a shared helper function in src/modifiers/modifier.ts (or a new utility file):
function processData1D(
modifier: LMPModifier,
data1D: Data1D | undefined,
input: ModifierInput,
everything: boolean,
syncDataPoints: boolean
): Data1D | undefinedThis function should handle:
- Getting
data1DNameswrapper and extracting size - Checking if data1D needs to be created
- Processing
clearPerSynclogic - Looping through
data1DVectorand extracting x/y values from WASM memory - Proper cleanup of all WASM objects
- Returning the processed
data1Dobject
Files to Modify
src/modifiers/modifier.ts(add helper function)- OR create new utility file if preferred
Benefits
- Reduces code duplication (~125 lines per file → ~50-60 lines)
- Makes maintenance easier (fix bugs/improvements in one place)
- Ensures consistent WASM memory cleanup
- Easier to add new modifiers in the future
Related
This is a prerequisite for issue #183 (memory leak fixes) and will make future improvements easier. Should be done after basic memory leak fixes.
Metadata
Metadata
Assignees
Labels
No labels