Store Transformations
Now, let's take a look at how Store is optimized. In Geajs, the compiler performs static analysis based on the way the Store is written and the file structure, and automatically applies transformations that minimize runtime overhead as much as possible.
| Category | Lean transformation | CompiledStore |
|---|---|---|
| Requirements | When the conditions are met in a “1 File, 1 Store” configuration | 1. For example, when there are multiple Stores in a single file, etc. |
| Runtime Base | CompiledLeanStore | CompiledStore |
| Optimization Level | Maximum (Object/Closure) | Standard (Class inheritance) |
| Fallback Risk | Low (Isolated) | High (All-or-nothing) |
- Lean Transformation
Lean Transformation is an optimization process that completely removes the class structure (
class ... extends Store) and rewrites it as lightweight JavaScript objects and closures.
Key Features and Benefits
-
Reduces the overhead of class inheritance: The cost of instance creation and prototype chain lookups is reduced to zero.
-
Maximizes memory efficiency: Since it does not carry unnecessary metadata, it enables lightweight state management.
-
Fast reactive tracking: Handles state change notifications with a minimal number of function calls.
- Static Analysis and Safety Controls for Array Operations
When state changes occur within a
Storeand involve destructive array methods (such assplice,pop,shift,unshift,sort, andreverse) or direct modifications to thelengthproperty, the compiler automatically inserts optimal monitoring logic to prevent reactive tracking inconsistencies.