cm0002@lemmy.world to Programmer Humor@programming.dev · 1 year agotimeoutSortlemmy.mlimagemessage-square3linkfedilinkarrow-up12arrow-down10
arrow-up12arrow-down1imagetimeoutSortlemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 1 year agomessage-square3linkfedilink
minus-squaresus@programming.devlinkfedilinkarrow-up0·1 year 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·1 year 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!