Skip to content

Commit

Permalink
minor optimization in case debug is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
r1j0 committed May 9, 2012
1 parent 716397c commit 4d08b5f
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/com/github/r1j0/statsd/configuration/StatsdConfiguration.java
Expand Up @@ -122,26 +122,27 @@ private void parseCommandLineOptions(final CommandLine line) {

private void initializeBackends() {
String[] backendsToUse = properties.getProperty(BACKEND_USE).split(",");
final Map<String, String> backendTypes = new HashMap<String, String>();

Map<String, String> backendTypes = new HashMap<String, String>();
Set<Entry<Object, Object>> entrySet = properties.entrySet();
if (isDebugEnabled()) {
backendsToUse = new String[] { "debug" };
backendTypes.put("debug", "debug");
} else {
Set<Entry<Object, Object>> entrySet = properties.entrySet();

for (Entry<Object, Object> entry : entrySet) {
final String key = (String) entry.getKey();
for (Entry<Object, Object> entry : entrySet) {
final String key = (String) entry.getKey();

if (!key.equals(BACKEND_USE) && key.matches("backend.*")) {
String identifier = key.substring(key.indexOf('.') + 1, key.lastIndexOf('.')).trim().toLowerCase();
if (!key.equals(BACKEND_USE) && key.matches("backend.*")) {
String identifier = key.substring(key.indexOf('.') + 1, key.lastIndexOf('.')).trim().toLowerCase();

if (key.endsWith("type")) {
backendTypes.put(identifier, getValue("backend." + identifier + ".type"));
if (key.endsWith("type")) {
backendTypes.put(identifier, getValue("backend." + identifier + ".type"));
}
}
}
}

if (isDebugEnabled()) {
backendsToUse = new String[] { "debug" };
}

for (String backendToUse : backendsToUse) {
final String backendIdentifier = backendToUse.trim();
final String backendType = backendTypes.get(backendIdentifier);
Expand Down

0 comments on commit 4d08b5f

Please sign in to comment.