Skip to content
This repository has been archived by the owner on Oct 18, 2018. It is now read-only.

Commit

Permalink
Bug 1081287: Use EnumMap where possible. r=rnewman
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisKitching committed Oct 11, 2014
1 parent b4badf4 commit de11690
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Expand Up @@ -5,7 +5,7 @@
package org.mozilla.gecko.fxa.login;

import java.security.NoSuchAlgorithmException;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Set;

import org.mozilla.gecko.background.fxa.FxAccountClient;
Expand All @@ -29,7 +29,7 @@ public static class ExecuteDelegate {
protected final LoginStateMachineDelegate delegate;
protected final StateLabel desiredStateLabel;
// It's as difficult to detect arbitrary cycles as repeated states.
protected final Set<StateLabel> stateLabelsSeen = new HashSet<StateLabel>();
protected final Set<StateLabel> stateLabelsSeen = EnumSet.noneOf(StateLabel.class);

protected ExecuteDelegate(StateLabel initialStateLabel, StateLabel desiredStateLabel, LoginStateMachineDelegate delegate) {
this.delegate = delegate;
Expand Down
Expand Up @@ -7,7 +7,9 @@
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;

import org.json.simple.parser.ParseException;
import org.mozilla.gecko.sync.GlobalSession;
Expand All @@ -34,7 +36,7 @@ public FxAccountGlobalSession(SyncConfiguration config,
@Override
public void prepareStages() {
super.prepareStages();
HashMap<Stage, GlobalSyncStage> stages = new HashMap<Stage, GlobalSyncStage>();
Map<Stage, GlobalSyncStage> stages = new EnumMap<>(Stage.class);
stages.putAll(this.stages);
stages.put(Stage.ensureClusterURL, new CheckPreconditionsStage());
this.stages = Collections.unmodifiableMap(stages);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/mozilla/gecko/sync/GlobalSession.java
Expand Up @@ -10,6 +10,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -174,7 +175,7 @@ public void executeCommand(final GlobalSession session, List<String> args) {
}

protected void prepareStages() {
HashMap<Stage, GlobalSyncStage> stages = new HashMap<Stage, GlobalSyncStage>();
Map<Stage, GlobalSyncStage> stages = new EnumMap<Stage, GlobalSyncStage>(Stage.class);

stages.put(Stage.checkPreconditions, new CheckPreconditionsStage());
stages.put(Stage.ensureClusterURL, new EnsureClusterURLStage(nodeAssignmentCallback));
Expand Down

0 comments on commit de11690

Please sign in to comment.