Skip to content

Commit

Permalink
[arraygen] Optimize in case where we do not need to store multiple exprs
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Nov 19, 2024
1 parent cac2560 commit b660418
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions src/plugins/score-plugin-fx/Fx/MathMapping_generic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,43 @@ struct GenericMathMapping
int size, value_output_callback& output, const std::string& expr,
const halp::tick_flicks& tk, State& self)
{
resize(expr, self, size);
if(size <= 1
|| (expr.find(":=") != std::string::npos && expr.find("po") != std::string::npos))
{
resize(expr, self, size);

setMathExpressionTiming(
self, tk.start_in_flicks, self.last_value_time, tk.relative_position);
self.last_value_time = tk.start_in_flicks;
setMathExpressionTiming(
self, tk.start_in_flicks, self.last_value_time, tk.relative_position);
self.last_value_time = tk.start_in_flicks;

GenericMathMapping::exec_polyphonic(self, output);
GenericMathMapping::exec_polyphonic(self, output);

std::vector<ossia::value> res;
res.resize(self.expressions.size());
for(int i = 0; i < self.expressions.size(); i++)
res[i] = (float)self.expressions[i].po;
std::vector<ossia::value> res;
res.resize(self.expressions.size());
for(int i = 0; i < self.expressions.size(); i++)
res[i] = (float)self.expressions[i].po;
// Combine
output(std::move(res));
}
else
{
resize(expr, self, 1);
setMathExpressionTiming(
self, tk.start_in_flicks, self.last_value_time, tk.relative_position);
self.last_value_time = tk.start_in_flicks;

std::vector<ossia::value> res;
res.resize(size);
for(int i = 0; i < size; i++)
{
auto& e = self.expressions[0];
e.instance = i;
res[i] = e.expr.result();

// Combine
output(std::move(res));
// po isn't used either store_output(e, res);
}
output(std::move(res));
}
}

static void run_polyphonic(
Expand Down

0 comments on commit b660418

Please sign in to comment.