Fix: revert optimizations
This commit is contained in:
@@ -122,7 +122,7 @@ impl App {
|
||||
}
|
||||
|
||||
pub fn execute_script_oneshot(
|
||||
&mut self,
|
||||
&self,
|
||||
script: &str,
|
||||
link: &LinkState,
|
||||
audio_tx: &arc_swap::ArcSwap<Sender<crate::engine::AudioCommand>>,
|
||||
|
||||
@@ -872,8 +872,6 @@ impl SequencerState {
|
||||
}
|
||||
}
|
||||
|
||||
let mut trace = ExecutionTrace::default();
|
||||
|
||||
for (_id, active) in self.audio_state.active_patterns.iter_mut() {
|
||||
let Some(pattern) = self.pattern_cache.get(active.bank, active.pattern) else {
|
||||
continue;
|
||||
@@ -939,9 +937,7 @@ impl SequencerState {
|
||||
mouse_down,
|
||||
};
|
||||
if let Some(script) = resolved_script {
|
||||
trace.executed_spans.clear();
|
||||
trace.selected_spans.clear();
|
||||
trace.resolved.clear();
|
||||
let mut trace = ExecutionTrace::default();
|
||||
if let Ok(cmds) = self
|
||||
.script_engine
|
||||
.evaluate_with_trace(script, &ctx, &mut trace)
|
||||
|
||||
@@ -147,26 +147,23 @@ pub(super) fn handle_main_page(ctx: &mut InputContext, key: KeyEvent, ctrl: bool
|
||||
}
|
||||
}
|
||||
KeyCode::Char('r') if ctrl => {
|
||||
let script = ctx
|
||||
.app
|
||||
.current_edit_pattern()
|
||||
.resolve_script(ctx.app.editor_ctx.step)
|
||||
.filter(|s| !s.trim().is_empty())
|
||||
.map(|s| s.to_owned());
|
||||
if let Some(script) = script {
|
||||
match ctx
|
||||
.app
|
||||
.execute_script_oneshot(&script, ctx.link, ctx.audio_tx)
|
||||
{
|
||||
Ok(()) => ctx
|
||||
let pattern = ctx.app.current_edit_pattern();
|
||||
if let Some(script) = pattern.resolve_script(ctx.app.editor_ctx.step) {
|
||||
if !script.trim().is_empty() {
|
||||
match ctx
|
||||
.app
|
||||
.ui
|
||||
.flash("Executed", 100, crate::state::FlashKind::Info),
|
||||
Err(e) => ctx.app.ui.flash(
|
||||
&format!("Error: {e}"),
|
||||
200,
|
||||
crate::state::FlashKind::Error,
|
||||
),
|
||||
.execute_script_oneshot(script, ctx.link, ctx.audio_tx)
|
||||
{
|
||||
Ok(()) => ctx
|
||||
.app
|
||||
.ui
|
||||
.flash("Executed", 100, crate::state::FlashKind::Info),
|
||||
Err(e) => ctx.app.ui.flash(
|
||||
&format!("Error: {e}"),
|
||||
200,
|
||||
crate::state::FlashKind::Error,
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ impl ScriptEngine {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn evaluate(&mut self, script: &str, ctx: &StepContext) -> Result<Vec<String>, String> {
|
||||
pub fn evaluate(&self, script: &str, ctx: &StepContext) -> Result<Vec<String>, String> {
|
||||
self.forth.evaluate(script, ctx)
|
||||
}
|
||||
|
||||
pub fn evaluate_with_trace(
|
||||
&mut self,
|
||||
&self,
|
||||
script: &str,
|
||||
ctx: &StepContext,
|
||||
trace: &mut ExecutionTrace,
|
||||
|
||||
@@ -43,7 +43,7 @@ pub fn update_cache(editor_ctx: &EditorContext) {
|
||||
let vars = Arc::new(ArcSwap::from_pointee(HashMap::new()));
|
||||
let dict = Arc::new(Mutex::new(HashMap::new()));
|
||||
let rng = Arc::new(Mutex::new(StdRng::seed_from_u64(42)));
|
||||
let mut engine = ScriptEngine::new(vars, dict, rng);
|
||||
let engine = ScriptEngine::new(vars, dict, rng);
|
||||
|
||||
let ctx = StepContext {
|
||||
step: 0,
|
||||
|
||||
Reference in New Issue
Block a user