shithub: puzzles

Download patch

ref: 76da6ec140cbbdac6136469ce50aab40e218f398
parent: 3e7a6adce5887db04d26438da64fdc4de308f4da
author: Ben Harris <bjh21@bjh21.me.uk>
date: Sat Jul 29 12:06:19 EDT 2023

js: keep colour strings in JavaScript rather than in C

The drawing routines in JavaScript used to take pointers to a C string
containing a CSS colour name.  That meant that JavaScript had to create
a new JavaScript string on ever call to a drawing function, which seemed
ugly.

So now we instead pass colour numbers all the way down into JavaScript
and keep an array of JavaScript strings there that can be re-used.  The
conversion from RGB triples to strings is still done in C, though.

This doesn't seem to have fixed either of the bugs I hoped it would, but
it does measurably improve drawing performance so I think it's worth
doing.