Closed Bug 1293007 Opened 8 years ago Closed 8 years ago

Replace in-tree consumer of non-standard Iterator() with Object.{values,entries} in mailnews/ in comm-central

Categories

(MailNews Core :: Backend, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 53.0

People

(Reporter: arai, Assigned: dwivedi.aman96)

References

Details

Attachments

(1 file, 2 obsolete files)

separated from bug 1290637. see bug 1290637 for the details. Required code changes are following: * Check each usage of non-standard Iterator [1] function, and replace it with Object.entries [2] or Object.values [3], or something appropriate for the specific usage Here's the rough list for Iterator() usage (not exhaustive) https://dxr.mozilla.org/comm-central/search?q=%22+Iterator(%22+path%3Amailnews%2F+-path%3Asuite%2F&redirect=false for example: for (let [k, v] in Iterator(obj)) { ... } can be replaced to: for (let [k, v] of Object.entries(obj)) { ... } another example: for (let [, v] in Iterator(array)) { ... } can be replaced to: for (let v of array) { ... } [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator [2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries [3] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values
Assignee: nobody → acelists
Component: MailNews: General → Backend
OS: Unspecified → All
Product: SeaMonkey → MailNews Core
Hardware: Unspecified → All
Hi Tooru! I would like to work on this. Can you assign it to me if not already fixed? :)
Flags: needinfo?(arai.unmht)
I think you can take this over. I'll re-assign this bug once you posted a patch ;) forwarding ni? to aceman just in case.
Flags: needinfo?(arai.unmht) → needinfo?(acelists)
Yes, you are welcome.
Assignee: acelists → dwivedi.aman96
Flags: needinfo?(acelists)
Status: NEW → ASSIGNED
Attached patch BugFix1293007.patch (obsolete) (deleted) — Splinter Review
Please have a look at the patch. :)
Attachment #8823761 - Flags: review?(arai.unmht)
Comment on attachment 8823761 [details] [diff] [review] BugFix1293007.patch Review of attachment 8823761 [details] [diff] [review]: ----------------------------------------------------------------- Thank you for your patch :) Please address the following comments and post updated patch. ::: mailnews/base/test/unit/test_autoconfigUtils.js @@ +66,4 @@ > function assert_equal_try_orders(aA, aB) > { > assert_equal(aA.length, aB.length, "tryOrders have different length"); > + for (let [i,subA] of Object.entries(aA)) { aA should be an array here, so you can use aA.entries() instead. ::: mailnews/base/test/unit/test_iteratorUtils.js @@ +132,4 @@ > do_check_true(childNodes.length > 0); > let childArray = iteratorUtils.toArray(childNodes); > do_check_eq(childNodes.length, childArray.length); > + for (let [i, node] of Object.entries(childArray)) here too. childArray is an array, and you can use childArray.entries() @@ +147,4 @@ > // returned by Iterator for an array > let iteratorArray = iteratorUtils.toArray(iterator); > do_check_eq(arr.length, iteratorArray.length); > + for (let [i, val] of Object.entries(arr)) { and here. @@ +183,4 @@ > }; > let iteratorArray = iteratorUtils.toArray(iterator); > do_check_eq(arr.length, iteratorArray.length); > + for (let [i, val] of Object.entries(arr)) and here. ::: mailnews/db/gloda/modules/datastore.js @@ +3530,4 @@ > aBoundArgs, aNounDef, aQuery, aListener, aListenerData, > aExistingCollection, aMasterCollection) { > let statement = this._createAsyncStatement(aSqlString, true); > + for (let [iBinding, bindingValue] of Object.entries(aBoundArgs)) { here too, aBoundArgs is an array and you can use aBoundArgs.entries() ::: mailnews/db/gloda/test/unit/test_fts3_tokenizer.js @@ +173,4 @@ > > // Bind the parameters > let stmt = conn.createStatement(sql); > + for (let [iBinding, bindingValue] of Object.entries(args)) { here too, args is an array ::: mailnews/test/resources/mailTestUtils.js @@ +476,4 @@ > * For when you want to compare elements non-strictly. > */ > non_strict_index_of: function(aArray, aElem) { > + for (let [i, elem] of Object.entries(aArray)) { here too, aArray is an array and you can use aArray.entries() ::: mailnews/test/resources/messageModifier.js @@ +127,4 @@ > msgHdrs: function*() { > // get the databases > let msgDatabases = this.msgFolders.map(folder => folder.msgDatabase); > + for (let [iMsg, synMsg] of Object.entries(this.synMessages)) { here too, this.synMessages is an array and you can use this.synMessages.entries() @@ +155,4 @@ > */ > get foldersWithMsgHdrs() { > let results = this.msgFolders.map(folder => [folder, []]); > + for (let [iMsg, synMsg] of Object.entries(this.synMessages)) { and here.
Attachment #8823761 - Flags: review?(arai.unmht) → feedback+
Attached patch BugFix1293007.patch (obsolete) (deleted) — Splinter Review
Thanks a lot! :)
Attachment #8823761 - Attachment is obsolete: true
Attachment #8823979 - Flags: review?(arai.unmht)
Comment on attachment 8823979 [details] [diff] [review] BugFix1293007.patch Review of attachment 8823979 [details] [diff] [review]: ----------------------------------------------------------------- Thanks again! looks good. forwarding review to aceman.
Attachment #8823979 - Flags: review?(arai.unmht)
Attachment #8823979 - Flags: review?(acelists)
Attachment #8823979 - Flags: feedback+
Comment on attachment 8823979 [details] [diff] [review] BugFix1293007.patch Review of attachment 8823979 [details] [diff] [review]: ----------------------------------------------------------------- Thanks arai for checking this. ::: mailnews/base/content/jsTreeView.js @@ +124,4 @@ > // for the next add item at our own level. > let currentCount = this._rowMap.length; > if (aChild.children.length && aChild.open) { > + for (let [i, child] of Array.from(this._rowMap[aNewIndex].children).entries()) { Why is this needed? Isn't this._rowMap[aNewIndex].children already an array? The comment at https://dxr.mozilla.org/comm-central/rev/97a86c21e6c33e5dbee5ce3045d9f4138d2260e2/mailnews/base/content/jsTreeView.js#17 seems to indicate so.
Attached patch BugFix1293007.patch (deleted) — Splinter Review
Thanks :aceman for pointing that out. This new patch should work.
Attachment #8823979 - Attachment is obsolete: true
Attachment #8823979 - Flags: review?(acelists)
Flags: needinfo?(acelists)
Attachment #8825343 - Flags: review?(acelists)
Comment on attachment 8825343 [details] [diff] [review] BugFix1293007.patch Review of attachment 8825343 [details] [diff] [review]: ----------------------------------------------------------------- Thanks.
Attachment #8825343 - Flags: review?(acelists) → review+
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Flags: needinfo?(acelists)
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 53.0
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: