Bug 159528

Summary: Use Array.forEach in Headers built-in constructor
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebCore Misc.Assignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: mark.lam
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 159296    
Bug Blocks:    
Attachments:
Description Flags
Patch none

youenn fablet
Reported 2016-07-07 15:31:06 PDT
Array.forEach can be used if it is shielded from public scripts.
Attachments
Patch (1.92 KB, patch)
2016-07-07 15:33 PDT, youenn fablet
no flags
youenn fablet
Comment 1 2016-07-07 15:33:52 PDT
Mark Lam
Comment 2 2016-07-11 13:02:52 PDT
Comment on attachment 283068 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=283068&action=review > Source/WebCore/Modules/fetch/FetchHeaders.js:44 > + @Array.prototype.@forEach.@call(headersInit, (header) => { Is this required by the spec? If not, is there a perf implication to this change?
youenn fablet
Comment 3 2016-07-11 13:14:08 PDT
(In reply to comment #2) > Comment on attachment 283068 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=283068&action=review > > > Source/WebCore/Modules/fetch/FetchHeaders.js:44 > > + @Array.prototype.@forEach.@call(headersInit, (header) => { > > Is this required by the spec? If not, is there a perf implication to this > change? No, it is not required and I do not think this makes any perf improvement since Array.forEach is using a for loop as well. This just makes the code smaller here.
Mark Lam
Comment 4 2016-07-11 14:39:46 PDT
Comment on attachment 283068 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=283068&action=review >>> Source/WebCore/Modules/fetch/FetchHeaders.js:44 >>> + @Array.prototype.@forEach.@call(headersInit, (header) => { >> >> Is this required by the spec? If not, is there a perf implication to this change? > > No, it is not required and I do not think this makes any perf improvement since Array.forEach is using a for loop as well. > This just makes the code smaller here. My concern is that it makes the code slower because you're adding a call to forEach which is not free, and it doesn't appear to be that much smaller. But maybe it's not such a big deal here. Just thought I'd ask.
youenn fablet
Comment 5 2016-07-12 03:00:20 PDT
Values iterator with a for-of loop seems a bit less expensive but it is still creating an iterator object. Maybe this is not worth it.
youenn fablet
Comment 6 2017-10-14 16:50:45 PDT
We no longer use builtins for creating headers thanks to improvement in the binding generator.
Note You need to log in before you can comment on or make changes to this bug.