Skip to content

Commit

Permalink
Use ImmutableSet instead of Set for constants (static final CONSTANT_…
Browse files Browse the repository at this point in the history
…CASE).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=148970514
  • Loading branch information
dorireuv authored and brad4d committed Mar 2, 2017
1 parent b5298fe commit d4a9ecd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
Expand Up @@ -30,7 +30,6 @@
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.Stack; import java.util.Stack;


/** /**
Expand Down Expand Up @@ -59,7 +58,7 @@ class AnalyzePrototypeProperties implements CompilerPass {
private final JSModule firstModule; private final JSModule firstModule;


// Properties that are implicitly used as part of the JS language. // Properties that are implicitly used as part of the JS language.
private static final Set<String> IMPLICITLY_USED_PROPERTIES = private static final ImmutableSet<String> IMPLICITLY_USED_PROPERTIES =
ImmutableSet.of("length", "toString", "valueOf"); ImmutableSet.of("length", "toString", "valueOf");


// A graph where the nodes are property names or variable names, // A graph where the nodes are property names or variable names,
Expand Down
22 changes: 7 additions & 15 deletions src/com/google/javascript/jscomp/NodeUtil.java
Expand Up @@ -65,14 +65,8 @@ public final class NodeUtil {
static final char LARGEST_BASIC_LATIN = 0x7f; static final char LARGEST_BASIC_LATIN = 0x7f;


/** the set of builtin constructors that don't have side effects. */ /** the set of builtin constructors that don't have side effects. */
private static final Set<String> CONSTRUCTORS_WITHOUT_SIDE_EFFECTS = private static final ImmutableSet<String> CONSTRUCTORS_WITHOUT_SIDE_EFFECTS =
ImmutableSet.of( ImmutableSet.of("Array", "Date", "Error", "Object", "RegExp", "XMLHttpRequest");
"Array",
"Date",
"Error",
"Object",
"RegExp",
"XMLHttpRequest");


// Utility class; do not instantiate. // Utility class; do not instantiate.
private NodeUtil() {} private NodeUtil() {}
Expand Down Expand Up @@ -1243,14 +1237,12 @@ static boolean constructorCallHasSideEffects(Node callNode) {
// A list of built-in object creation or primitive type cast functions that // A list of built-in object creation or primitive type cast functions that
// can also be called as constructors but lack side-effects. // can also be called as constructors but lack side-effects.
// TODO(johnlenz): consider adding an extern annotation for this. // TODO(johnlenz): consider adding an extern annotation for this.
private static final Set<String> BUILTIN_FUNCTIONS_WITHOUT_SIDEEFFECTS = private static final ImmutableSet<String> BUILTIN_FUNCTIONS_WITHOUT_SIDEEFFECTS =
ImmutableSet.of( ImmutableSet.of("Object", "Array", "String", "Number", "Boolean", "RegExp", "Error");
"Object", "Array", "String", "Number", "Boolean", "RegExp", "Error"); private static final ImmutableSet<String> OBJECT_METHODS_WITHOUT_SIDEEFFECTS =
private static final Set<String> OBJECT_METHODS_WITHOUT_SIDEEFFECTS =
ImmutableSet.of("toString", "valueOf"); ImmutableSet.of("toString", "valueOf");
private static final Set<String> REGEXP_METHODS = private static final ImmutableSet<String> REGEXP_METHODS = ImmutableSet.of("test", "exec");
ImmutableSet.of("test", "exec"); private static final ImmutableSet<String> STRING_REGEXP_METHODS =
private static final Set<String> STRING_REGEXP_METHODS =
ImmutableSet.of("match", "replace", "search", "split"); ImmutableSet.of("match", "replace", "search", "split");


/** /**
Expand Down

0 comments on commit d4a9ecd

Please sign in to comment.