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:
parent
ddf39a5092
commit
7966167cf6
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue