Replace double tilde with `Math.floor` (#30691)

Nowadays, browser engines have improved a lot and `Math.floor` is the same, if not faster.
Also, clarity is better than micro-optimizations in this case.
This commit is contained in:
XhmikosR 2020-05-14 09:46:42 +03:00 committed by GitHub
parent ddf39a5092
commit 7966167cf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -26,7 +26,7 @@ const toType = obj => {
const getUID = prefix => {
do {
prefix += ~~(Math.random() * MAX_UID) // "~~" acts like a faster Math.floor() here
prefix += Math.floor(Math.random() * MAX_UID)
} while (document.getElementById(prefix))
return prefix