by Ricardo “Rudxain” Fernández Serrata
Version 2 (March 20, 2023)
Download (69 downloads)
More efficient in time, space, and energy.
The fork-block is only used for responsiveness (because get-setting and "toast" have latency, that could prevent content-changed from detecting an update), you can use a simple loop if you don't need too much responsiveness.
`s & 3` exists because dictionaries are expensive, so I tried to find something that allows optimization, and noticed that the 4th char of all categories at the rightmost (least significant) bits, matches their IDs (`system` is `0b00`, `secure` is `0b01`, `global` is `0b10`). I used `& 3` instead of `% 4` because of a benchmark I did on my device where "modulo" was slower than "bit and". Bitwise ops require 2-way float-int conversions, but they seem faster than division.
Rate and review within the app in the Community section.