-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[api-minor] Sort PopupAnnotations already on the worker-thread (PR 11535 follow-up) #15283
[api-minor] Sort PopupAnnotations already on the worker-thread (PR 11535 follow-up) #15283
Conversation
…535 follow-up) By doing this in the worker-thread this code will only need to run *once*, whereas currently re-rendering of a page forces this to be repeated (e.g. after it's been scrolled out-of-view and then back into view again).
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/90980c0f93a2643/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/4e9ff5acf599168/output.txt |
@@ -656,7 +656,32 @@ class Page { | |||
} | |||
|
|||
return Promise.all(annotationPromises).then(function (annotations) { | |||
return annotations.filter(annotation => !!annotation); | |||
if (annotations.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can be simplified in using sort function.
I just tried:
["a",1, 2, "d", "e", 3, "aa"].sort((a, b) => typeof a === typeof b ? 0 : (typeof a === "string" ? -1 : +1))
and it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I'm not finding such a code-snippet particularly easy to read/understand at a glance.
Also, wouldn't you still need to filter
out any empty entries first? If so, that'd effectively require two loops through the Array rather than just the one.
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/90980c0f93a2643/output.txt Total script time: 25.89 mins
Image differences available at: http://54.241.84.105:8877/90980c0f93a2643/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/4e9ff5acf599168/output.txt Total script time: 30.22 mins
Image differences available at: http://54.193.163.58:8877/4e9ff5acf599168/reftest-analyzer.html#web=eq.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Looks good! |
By doing this in the worker-thread this code will only need to run once, whereas currently re-rendering of a page forces this to be repeated (e.g. after it's been scrolled out-of-view and then back into view again).