Skip to content

Commit 4ae3f6e

Browse files
authored
[jscompiler] Cleanup warn/warnOnce utility functions. NFC (#23727)
I'm not sure why we have the two argument versions of these functions. The two-argument version of warnOnce was introduced in ca58e84 but doesn't seem to have ever had any callers. The two-argument version of `warn` was introduced in 46e3b2a, but I can't see any users of it from back then. It was modified to take a single argument in 06b58cb.
1 parent 6fcf73c commit 4ae3f6e

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/utility.mjs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,16 @@ function errorPrefix() {
6262
}
6363
}
6464

65-
export function warn(a, msg) {
65+
export function warn(msg) {
6666
warnings = true;
67-
if (!msg) {
68-
msg = a;
69-
a = false;
70-
}
71-
if (!a) {
72-
printErr(`warning: ${errorPrefix()}${msg}`);
73-
}
67+
printErr(`warning: ${errorPrefix()}${msg}`);
7468
}
7569

76-
export function warnOnce(a, msg) {
77-
if (!msg) {
78-
msg = a;
79-
a = false;
80-
}
81-
if (!a) {
82-
warnOnce.msgs ||= {};
83-
if (msg in warnOnce.msgs) return;
84-
warnOnce.msgs[msg] = true;
70+
const seenWarnings = new Set();
71+
72+
export function warnOnce(msg) {
73+
if (!seenWarnings.has(msg)) {
74+
seenWarnings.add(msg);
8575
warn(msg);
8676
}
8777
}

0 commit comments

Comments
 (0)