<commit_before>// Copyright (C) 2003-2009 by Object Mentor, Inc. All rights reserved.
// Released under the terms of the CPL Common Public License version 1.0.
package fitnesse.testsystems.slim;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import fitnesse.testsystems.ExecutionResult;
import fitnesse.testsystems.TestPage;
import fitnesse.testsystems.TestSummary;
import fitnesse.testsystems.slim.tables.ScenarioTable;

public class SlimTestContextImpl implements SlimTestContext {
  private final Map<String, String> symbols = new HashMap<>();
  private final Map<String, ScenarioTable> scenarios = new HashMap<>();
  private final TestSummary testSummary = new TestSummary();
  private final TestPage pageToTest;
  private final List<ScenarioTable> scenariosWithInputs = new ArrayList<>();
  private boolean isSorted = false;

  public SlimTestContextImpl(TestPage pageToTest) {
    this.pageToTest = pageToTest;
  }

  @Override
  public String getSymbol(String symbolName) {
    return symbols.get(symbolName);
  }

  @Override
  public void setSymbol(String symbolName, String value) {
    symbols.put(symbolName, value);
  }

  @Override
  public void addScenario(String scenarioName, ScenarioTable scenarioTable) {
    ScenarioTable oldValue = scenarios.put(scenarioName, scenarioTable);
    if (oldValue != null && !oldValue.getInputs().isEmpty()) {
      scenariosWithInputs.remove(oldValue);
    }
    if (!scenarioTable.getInputs().isEmpty()) {
      scenariosWithInputs.add(scenarioTable);
      isSorted = false;
    }
  }

  @Override
  public ScenarioTable getScenario(String scenarioName) {
    return scenarios.get(scenarioName);<commit_msg>Initial collections should have larger sizes than Java defaults (16 for hashmap and 8 for list) since the number of scenarios could be much larger and resizing collections is much more expensive than having/allocating larger ones for each test.<commit_after>// Copyright (C) 2003-2009 by Object Mentor, Inc. All rights reserved.
// Released under the terms of the CPL Common Public License version 1.0.
package fitnesse.testsystems.slim;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import fitnesse.testsystems.ExecutionResult;
import fitnesse.testsystems.TestPage;
import fitnesse.testsystems.TestSummary;
import fitnesse.testsystems.slim.tables.ScenarioTable;

public class SlimTestContextImpl implements SlimTestContext {
  private final Map<String, String> symbols = new HashMap<>();
  private final Map<String, ScenarioTable> scenarios = new HashMap<>(512);
  private final TestSummary testSummary = new TestSummary();
  private final TestPage pageToTest;
  private final List<ScenarioTable> scenariosWithInputs = new ArrayList<>(256);
  private boolean isSorted = false;

  public SlimTestContextImpl(TestPage pageToTest) {
    this.pageToTest = pageToTest;
  }

  @Override
  public String getSymbol(String symbolName) {
    return symbols.get(symbolName);
  }

  @Override
  public void setSymbol(String symbolName, String value) {
    symbols.put(symbolName, value);
  }

  @Override
  public void addScenario(String scenarioName, ScenarioTable scenarioTable) {
    ScenarioTable oldValue = scenarios.put(scenarioName, scenarioTable);
    if (oldValue != null && !oldValue.getInputs().isEmpty()) {
      scenariosWithInputs.remove(oldValue);
    }
    if (!scenarioTable.getInputs().isEmpty()) {
      scenariosWithInputs.add(scenarioTable);
      isSorted = false;
    }
  }

  @Override
  public ScenarioTable getScenario(String scenarioName) {
    return scenarios.get(scenarioName);
{'fraction_non_alphanumeric': 0.0895600104139547, 'fraction_numerical': 0.007550117156990367, 'mean_word_length': 4.901689708141321, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3517861', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1085, 'n_words': 307}