cm0002@lemmy.world to Programmer Humor@programming.dev · 10 days agotimeoutSortlemmy.mlimagemessage-square10linkfedilinkarrow-up13arrow-down10
arrow-up13arrow-down1imagetimeoutSortlemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 10 days agomessage-square10linkfedilink
minus-squaresus@programming.devlinkfedilinkarrow-up0·10 days agoit’s while (true) { let t = Date.now(); if (timeoutMap.has(t)) timeoutMap[t](); } of course. Clearly O(n). disclaimer Feel free to use it. I guarantee it is bug free. Comes with express warranty. This notice is legally binding.
minus-squareFooBarrington@lemmy.worldlinkfedilinkarrow-up1·9 days agoI found a way to optimize your code without affecting the result. By making it branchless, I was able to get my CPU to 100% utilization!
it’s
while (true) { let t = Date.now(); if (timeoutMap.has(t)) timeoutMap[t](); }of course. Clearly O(n).
disclaimer
Feel free to use it. I guarantee it is bug free. Comes with express warranty. This notice is legally binding.
I found a way to optimize your code without affecting the result. By making it branchless, I was able to get my CPU to 100% utilization!