MCPcopy Create free account
hub / github.com/aiscriptdev/aiscript / optimize

Method optimize

aiscript-vm/src/compiler/optimizer/mod.rs:37–51  ·  view source on GitHub ↗

Optimize the given chunk using all registered strategies

(&self, chunk: &mut Chunk)

Source from the content-addressed store, hash-verified

35
36 /// Optimize the given chunk using all registered strategies
37 pub fn optimize(&self, chunk: &mut Chunk) {
38 let mut modified = true;
39 let mut iteration = 0;
40 const MAX_ITERATIONS: usize = 10; // Prevent infinite loops
41
42 while modified && iteration < MAX_ITERATIONS {
43 modified = false;
44 for strategy in &self.strategies {
45 if strategy.optimize(chunk) {
46 modified = true;
47 }
48 }
49 iteration += 1;
50 }
51 }
52}

Callers 1

compileFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected