Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(554)

Issue 1833573006: Distinguish SimpleIdentifier uses and declarations at parse time. (Closed)

Created:
4 years, 9 months ago by Bob Nystrom
Modified:
4 years, 8 months ago
Reviewers:
Brian Wilkerson
CC:
reviews_dartlang.org
Base URL:
https://github.com/dart-lang/sdk.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Distinguish SimpleIdentifier uses and declarations at parse time. Instead of a very slow .inDeclarationContext() method which determines whether a given identifier is in a use position or not, we just create a different subclass at parse time that encodes that fact directly. Also, remove an unnecessary _validateElement() method. On my Mac laptop, this takes benchmark/errors_in_all_libraries.dart From: 0:00:05.673849 To: 0:00:05.193563 (91.53%) R=brianwilkerson@google.com Committed: https://github.com/dart-lang/sdk/commit/31aa8e26df435226bc739e0ac6102381efe0beb1

Patch Set 1 #

Total comments: 4

Patch Set 2 : Brace body. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+93 lines, -272 lines) Patch
M pkg/analyzer/lib/dart/ast/ast.dart View 1 1 chunk +6 lines, -1 line 0 comments Download
M pkg/analyzer/lib/src/dart/ast/ast.dart View 5 chunks +21 lines, -102 lines 0 comments Download
M pkg/analyzer/lib/src/dart/ast/utilities.dart View 2 chunks +4 lines, -2 lines 0 comments Download
M pkg/analyzer/lib/src/generated/parser.dart View 41 chunks +62 lines, -49 lines 0 comments Download
M pkg/analyzer/test/dart/ast/ast_test.dart View 1 chunk +0 lines, -118 lines 0 comments Download

Messages

Total messages: 7 (2 generated)
Bob Nystrom
4 years, 9 months ago (2016-03-24 23:44:20 UTC) #2
Brian Wilkerson
LGTM https://codereview.chromium.org/1833573006/diff/1/pkg/analyzer/lib/dart/ast/ast.dart File pkg/analyzer/lib/dart/ast/ast.dart (right): https://codereview.chromium.org/1833573006/diff/1/pkg/analyzer/lib/dart/ast/ast.dart#newcode6708 pkg/analyzer/lib/dart/ast/ast.dart:6708: if (isDeclaration) return new DeclaredSimpleIdentifier(token); nit: block https://codereview.chromium.org/1833573006/diff/1/pkg/analyzer/lib/src/generated/parser.dart ...
4 years, 9 months ago (2016-03-25 15:37:31 UTC) #3
Bob Nystrom
Committed patchset #2 (id:20001) manually as 31aa8e26df435226bc739e0ac6102381efe0beb1 (presubmit successful).
4 years, 9 months ago (2016-03-25 17:38:27 UTC) #5
Paul Berry
On 2016/03/25 17:38:27, Bob Nystrom wrote: > Committed patchset #2 (id:20001) manually as > 31aa8e26df435226bc739e0ac6102381efe0beb1 ...
4 years, 8 months ago (2016-03-28 15:29:10 UTC) #6
Bob Nystrom
4 years, 8 months ago (2016-03-28 16:09:16 UTC) #7
Message was sent while issue was closed.
https://codereview.chromium.org/1833573006/diff/1/pkg/analyzer/lib/dart/ast/a...
File pkg/analyzer/lib/dart/ast/ast.dart (right):

https://codereview.chromium.org/1833573006/diff/1/pkg/analyzer/lib/dart/ast/a...
pkg/analyzer/lib/dart/ast/ast.dart:6708: if (isDeclaration) return new
DeclaredSimpleIdentifier(token);
On 2016/03/25 15:37:31, Brian Wilkerson wrote:
> nit: block

Haha, fixed. I swear one day I will remember to not do this.

https://codereview.chromium.org/1833573006/diff/1/pkg/analyzer/lib/src/genera...
File pkg/analyzer/lib/src/generated/parser.dart (right):

https://codereview.chromium.org/1833573006/diff/1/pkg/analyzer/lib/src/genera...
pkg/analyzer/lib/src/generated/parser.dart:2575: new
SimpleIdentifier(methodName.token, isDeclaration: false),
On 2016/03/25 15:37:31, Brian Wilkerson wrote:
> Why do we need to create a different node? We passed `true` in when parsing
the
> identifier. (Here and several places below.)

Great question. It's because the methodName parsed on 2564 is used in a
declaration context in some code paths but not in others. On 2587, it's a
declaration context (the constructor name). Here, it's not (it's the return
type). The other similar cases below are the same thing. We parse an identifier
once but it may conditionally end up in a declaration context or not.

There's probably a more elegant way to rearrange the code and only create the
identifier once, but I was trying to minimize the impact of the optimization.
When we've got a little more time, I'm hoping we can do a more comprehensive fix
by splitting SimpleIdentifier and DeclaredSimpleIdentifier completely. If that
happens, it will probably make sense to rearrange the parsing code a little bit
too.

Powered by Google App Engine
This is Rietveld 408576698