summaryrefslogtreecommitdiff
path: root/ext/node
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node')
-rw-r--r--ext/node/global.rs24
1 files changed, 21 insertions, 3 deletions
diff --git a/ext/node/global.rs b/ext/node/global.rs
index 0fc215bd4..0b4adfc7d 100644
--- a/ext/node/global.rs
+++ b/ext/node/global.rs
@@ -63,8 +63,9 @@ const fn str_to_utf16<const N: usize>(s: &str) -> [u16; N] {
// UTF-16 encodings of the managed globals. THIS LIST MUST BE SORTED.
#[rustfmt::skip]
-const MANAGED_GLOBALS: [&[u16]; 13] = [
+const MANAGED_GLOBALS: [&[u16]; 14] = [
&str_to_utf16::<6>("Buffer"),
+ &str_to_utf16::<17>("WorkerGlobalScope"),
&str_to_utf16::<14>("clearImmediate"),
&str_to_utf16::<13>("clearInterval"),
&str_to_utf16::<12>("clearTimeout"),
@@ -79,8 +80,25 @@ const MANAGED_GLOBALS: [&[u16]; 13] = [
&str_to_utf16::<6>("window"),
];
-const SHORTEST_MANAGED_GLOBAL: usize = 4;
-const LONGEST_MANAGED_GLOBAL: usize = 14;
+// Calculates the shortest & longest length of global var names
+const MANAGED_GLOBALS_INFO: (usize, usize) = {
+ let l = MANAGED_GLOBALS[0].len();
+ let (mut longest, mut shortest, mut i) = (l, l, 1);
+ while i < MANAGED_GLOBALS.len() {
+ let l = MANAGED_GLOBALS[i].len();
+ if l > longest {
+ longest = l
+ }
+ if l < shortest {
+ shortest = l
+ }
+ i += 1;
+ }
+ (shortest, longest)
+};
+
+const SHORTEST_MANAGED_GLOBAL: usize = MANAGED_GLOBALS_INFO.0;
+const LONGEST_MANAGED_GLOBAL: usize = MANAGED_GLOBALS_INFO.1;
#[derive(Debug, Clone, Copy)]
enum Mode {