Micro-optimise

This commit is contained in:
Andras Schmelczer 2026-06-10 21:41:56 +01:00
parent c207970e87
commit 042e4d05c7

View file

@ -53,6 +53,13 @@ export class UniformArrayAutoScalingProgram implements IProgram {
} }
await Promise.all(promises); await Promise.all(promises);
// draw() takes the first program with enough capacity; ordering by total
// capacity makes that the cheapest sufficient variant instead of an
// arbitrary one full of phantom objects.
this.programs.sort(
(a, b) => a.values.reduce((s, v) => s + v, 0) - b.values.reduce((s, v) => s + v, 0)
);
} }
private checkDescriptorValidity(descriptors: Array<DrawableDescriptor>) { private checkDescriptorValidity(descriptors: Array<DrawableDescriptor>) {