0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-26 23:54:23 +01:00

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

View File

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