<commit_before>(function() {
  'use strict';

  function StatusDisplay(_d3, ComponentsFactory, StatusDisplayLayoutFactory) {

    function StatusDisplayController() {
    }

    function StatusDisplayLink(scope, elem, attr, ngModelCtrl) {
      ngModelCtrl.$render = draw;

      function draw() {
        angular.element(elem[0]).empty();

        var componentsFactory = new ComponentsFactory();
        var systemStatus = ngModelCtrl.$modelValue;

        var svg = _d3.select(elem[0]).append('svg:svg');
        var componentsContainer = svg.append('svg:g');

        var aquarium = componentsFactory.getAquarium(componentsContainer);
        var sump = componentsFactory.getSump(componentsContainer);
        var lights = componentsFactory.getLights(componentsContainer, systemStatus.lights);
        var pump = componentsFactory.getPump(componentsContainer, systemStatus.pump);
        var aquariumReturn = componentsFactory.getAquariumReturn(componentsContainer);
        var sumpReturn = componentsFactory.getSumpReturn(componentsContainer);

        var statusDisplayLayoutFactory = new StatusDisplayLayoutFactory(aquarium, sump, lights, pump, aquariumReturn, sumpReturn);
        statusDisplayLayoutFactory.layout(svg);
      }
    }

    return {
      restrict: 'E',
      require: 'ngModel',
      controller: StatusDisplayController,
      controllerAs: 'ctrl',
      link: StatusDisplayLink
    };
  }

  angular.module('aquamonitor.core')
  .directive('statusDisplay', StatusDisplay);
})();
<commit_msg>Moved creation of components factory outside of draw callback<commit_after>(function() {
  'use strict';

  function StatusDisplay(_d3, ComponentsFactory, StatusDisplayLayoutFactory) {

    function StatusDisplayController() {
    }

    function StatusDisplayLink(scope, elem, attr, ngModelCtrl) {
      var componentsFactory = new ComponentsFactory();
      ngModelCtrl.$render = draw;

      function draw() {
        angular.element(elem[0]).empty();

        var systemStatus = ngModelCtrl.$modelValue;
        var svg = _d3.select(elem[0]).append('svg:svg');
        var componentsContainer = svg.append('svg:g');

        var aquarium = componentsFactory.getAquarium(componentsContainer);
        var sump = componentsFactory.getSump(componentsContainer);
        var lights = componentsFactory.getLights(componentsContainer, systemStatus.lights);
        var pump = componentsFactory.getPump(componentsContainer, systemStatus.pump);
        var aquariumReturn = componentsFactory.getAquariumReturn(componentsContainer);
        var sumpReturn = componentsFactory.getSumpReturn(componentsContainer);

        var statusDisplayLayoutFactory = new StatusDisplayLayoutFactory(aquarium, sump, lights, pump, aquariumReturn, sumpReturn);
        statusDisplayLayoutFactory.layout(svg);
      }
    }

    return {
      restrict: 'E',
      require: 'ngModel',
      controller: StatusDisplayController,
      controllerAs: 'ctrl',
      link: StatusDisplayLink
    };
  }

  angular.module('aquamonitor.core')
  .directive('statusDisplay', StatusDisplay);
})();

{'fraction_non_alphanumeric': 0.10120012974375608, 'fraction_numerical': 0.0025948751216347712, 'mean_word_length': 3.849056603773585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3848453', 'n_tokens_mistral': 809, 'n_tokens_neox': 791, 'n_words': 160}