PreParsing inner funcs: Do fewer variable name lookups.

It's unnecessarily to first lookup and then insert.

BUG=v8:5501

Review-Url: https://codereview.chromium.org/2608333003
Cr-Commit-Position: refs/heads/master@{#42065}
This commit is contained in:
marja 2017-01-04 03:58:20 -08:00 committed by Commit bot
parent fcffcba725
commit 11d13027e8
2 changed files with 4 additions and 5 deletions

View File

@ -1037,11 +1037,10 @@ void Scope::DeclareVariableName(const AstRawString* name, VariableMode mode) {
DCHECK(!is_eval_scope());
DCHECK(is_declaration_scope() ||
(IsLexicalVariableMode(mode) && is_block_scope()));
DCHECK(scope_info_.is_null());
// Declare the variable in the declaration scope.
if (LookupLocal(name) == nullptr) {
variables_.DeclareName(zone(), name);
}
variables_.DeclareName(zone(), name);
}
VariableProxy* Scope::NewUnresolved(AstNodeFactory* factory,

View File

@ -34,8 +34,8 @@ class VariableMap: public ZoneHashMap {
MaybeAssignedFlag maybe_assigned_flag = kNotAssigned,
bool* added = nullptr);
// Records that "name" exists but doesn't create a Variable. Useful for
// preparsing.
// Records that "name" exists (if not recorded yet) but doesn't create a
// Variable. Useful for preparsing.
void DeclareName(Zone* zone, const AstRawString* name);
Variable* Lookup(const AstRawString* name);