From: XhmikosR Date: Thu, 14 May 2020 06:46:42 +0000 (+0300) Subject: Replace double tilde with `Math.floor` (#30691) X-Git-Tag: v5.0.0-alpha1~113 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7966167cf6d52ce1841b9f1d2d37700ec7d2b3c4;p=thirdparty%2Fbootstrap.git 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. --- diff --git a/js/src/util/index.js b/js/src/util/index.js index cee4034811..f92c7eb5d7 100644 --- a/js/src/util/index.js +++ b/js/src/util/index.js @@ -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