Skip to content

Commit

Permalink
[resultsdb] rewrite JS unexpectedResults for clarity
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=270448
rdar://problem/124013364

Reviewed by Jonathan Bedard.

Based on profiling in both Safari and Chrome, this doesn't meaningfully
change the performance of the hot code. In either browser,
unexpectedResults scarcely manages to get sampled.

* Tools/Scripts/libraries/resultsdbpy/resultsdbpy/view/static/js/expectations.js:
(Expectations.unexpectedResults):

Canonical link: https://commits.webkit.org/275628@main
  • Loading branch information
gsnedders committed Mar 4, 2024
1 parent 704de66 commit aff41c9
Showing 1 changed file with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,22 @@ class Expectations

static unexpectedResults(results, expectations)
{
let r = results.split('.');
expectations.split(' ').forEach(expectation => {
const i = r.indexOf(expectation);
if (i > -1)
r.splice(i, 1);
if (expectation === 'FAIL')
['TEXT', 'AUDIO', 'IMAGE'].forEach(expectation => {
const i = r.indexOf(expectation);
if (i > -1)
r.splice(i, 1);
});
});
const unexpectedSet = new Set(results.split('.'));
const expectedSet = new Set(expectations.split(' '));

if (expectedSet.has('FAIL'))
expectedSet.add('TEXT').add('AUDIO').add('IMAGE');

for (const result of unexpectedSet) {
if (expectedSet.has(result))
unexpectedSet.delete(result);
}

let result = 'PASS';
r.forEach(candidate => {
for (const candidate of unexpectedSet) {
if (Expectations.stringToStateId(candidate) < Expectations.stringToStateId(result))
result = candidate;
});
}
return result;
}
}
Expand Down

0 comments on commit aff41c9

Please sign in to comment.