Source:
<code>private void getStateStatus(final TeamWorkFlowArtifact currWf, final IStateToken currState) { if (!this.getValueText().equals("")) { return; } Composite tasksCompositeLabel = new Composite(this.compositeLabel, SWT.LEFT); HashMap<String, Integer> countingMap = new HashMap<String, Integer>(); HashMap<String, Integer> colorMap = new HashMap<String, Integer>(); int numStates = 0; for (IAtsTask task : AtsClientService.get().getTaskService().getTasks(currWf)) { if <START> (countingMap.containsKey(task.getStateDefinition().getName())) <END> { countingMap.put(task.getStateDefinition().getName(), countingMap.get(task.getStateDefinition().getName()) + 1); } else { countingMap.put(task.getStateDefinition().getName(), 1); StateColor currColor = task.getStateDefinition().getColor(); if (currColor == null) { currColor = StateColor.BLACK; } colorMap.put(task.getStateDefinition().getName(), StateColorToSwtColor.convert(currColor)); } numStates++; } if (numStates < 3) { numStates = 3; } tasksCompositeLabel.setLayout(new GridLayout(numStates, false)); tasksCompositeLabel.setLayoutData(new GridData(SWT.NONE, SWT.NONE, true, false)); setValueText(String.format(" Total: %d | Current State \"%s\": %s", numStates, currState.getName(), AtsClientService.get().getTaskService().getTasks(currWf, currState).size())); Label leftAlignLab = new Label(tasksCompositeLabel, SWT.NONE); leftAlignLab.setText("\n "); for (String key : countingMap.keySet()) { Label lab = new Label(tasksCompositeLabel, SWT.NONE); lab.setText("\"" + key + "\"" + ": " + countingMap.get(key) + " "); lab.setForeground(Displays.getSystemColor(colorMap.get(key))); } }</code><technical_language>call this store a variable is currently called multiple times</technical_language>

Target:
private void getStateStatus(final TeamWorkFlowArtifact currWf, final IStateToken currState) { if (!this.getValueText().equals("")) { return; } Composite tasksCompositeLabel = new Composite(this.compositeLabel, SWT.LEFT); HashMap<String, Integer> countingMap = new HashMap<String, Integer>(); HashMap<String, Integer> colorMap = new HashMap<String, Integer>(); int numStates = 0; for (IAtsTask task : AtsClientService.get().getTaskService().getTasks(currWf)) { String currTaskName = task.getStateDefinition().getName(); if (countingMap.containsKey(currTaskName)) { countingMap.put(currTaskName, countingMap.get(currTaskName) + 1); } else { countingMap.put(currTaskName, 1); StateColor currColor = task.getStateDefinition().getColor(); if (currColor == null) { currColor = StateColor.BLACK; } colorMap.put(currTaskName, StateColorToSwtColor.convert(currColor)); } numStates++; } if (numStates < 3) { numStates = 3; } tasksCompositeLabel.setLayout(new GridLayout(numStates, false)); tasksCompositeLabel.setLayoutData(new GridData(SWT.NONE, SWT.NONE, true, false)); setValueText(String.format(" Total: %d | Current State \"%s\": %s", numStates, currState.getName(), AtsClientService.get().getTaskService().getTasks(currWf, currState).size())); Label leftAlignLab = new Label(tasksCompositeLabel, SWT.NONE); leftAlignLab.setText(" "); for (String key : countingMap.keySet()) { Label lab = new Label(tasksCompositeLabel, SWT.NONE); lab.setText("\"" + key + "\"" + ": " + countingMap.get(key) + " "); lab.setForeground(Displays.getSystemColor(colorMap.get(key))); } }