From 042e4d05c7fbf49dbf57aa64db3bcf25937f1016 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Wed, 10 Jun 2026 21:41:56 +0100 Subject: [PATCH] Micro-optimise --- .../program/uniform-array-autoscaling-program.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/graphics/graphics-library/program/uniform-array-autoscaling-program.ts b/src/graphics/graphics-library/program/uniform-array-autoscaling-program.ts index 80c9d1a..cd0d86c 100644 --- a/src/graphics/graphics-library/program/uniform-array-autoscaling-program.ts +++ b/src/graphics/graphics-library/program/uniform-array-autoscaling-program.ts @@ -53,6 +53,13 @@ export class UniformArrayAutoScalingProgram implements IProgram { } 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) {