Closed Bug 976596 Opened 7 years ago Closed 7 years ago

Block-scoped variables indexing refactor

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla30

People

(Reporter: wingo, Assigned: wingo)

Details

Attachments

(1 file)

This is a followup to bug 962599 comment 26, to refactor some namings in block scope objects.
Assignee: nobody → wingo
Attachment #8381463 - Flags: review?(luke)
Comment on attachment 8381463 [details] [diff] [review]
Block-scoped variables indexing refactor

Review of attachment 8381463 [details] [diff] [review]:
-----------------------------------------------------------------

Great!

::: js/src/vm/ScopeObject.h
@@ +410,1 @@
>          return propertyCount();

I was just looking at this and I was astounded to see that propertyCount() is O(n)!  Could you add a
  // TODO: propertyCount() is O(n), use O(1) lastProperty()->slot() instead
here?  (Even worse, numVariables() is used in loop conditions, making the loops O(n^2)!)
Attachment #8381463 - Flags: review?(luke) → review+
(In reply to Luke Wagner [:luke] from comment #2)

> I was just looking at this and I was astounded to see that propertyCount()
> is O(n)!

Yuck!  Good catch.  Added the comment.
https://hg.mozilla.org/mozilla-central/rev/f05165839760
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla30
You need to log in before you can comment on or make changes to this bug.