<commit_before>
var NotificationsController = SingleModelController.createComponent("NotificationsController");

NotificationsController.defineAlias("model", "notifications");

NotificationsController.defineMethod("updateView", function () {
  if (!this.view) return;

  var bottom = 0;
  this.notifications.notifications = this.notifications.notifications.filter(function (notification) {
    var element = this.view.querySelector("[data-ica-notification-id='{0}']".format(notification.componentId));

    // Check existing element
    if (element) {
      element.style.bottom = bottom + "px";
    } else {
      // Create new view
      var fragment;
      switch (notification.constructor) {
      case BasicNotification:
        fragment = BasicNotificationController.createViewFragment();
        element = fragment.querySelector(".notification");
        element.style.bottom = bottom + "px";
        this.view.appendChild(fragment);
        new BasicNotificationController(notification, element).componentOf = this;
        break;
      case ProgressNotification:
      case XHRProgressNotification:
        fragment = XHRProgressNotificationController.createViewFragment();
        element = fragment.querySelector(".notification");
        element.style.bottom = bottom + "px";
        this.view.appendChild(fragment);
        new XHRProgressNotificationController(notification, element).componentOf = this;
        break;
      default:
        console.warn("Unhandled item:", notification.constructor);
        return false;
      }
    }

    bottom += element.offsetHeight + 8; // 16 px margin top & bottom

    return true;
  }.bind(this));
});<commit_msg>Optimize controller view update<commit_after>
var NotificationsController = SingleModelController.createComponent("NotificationsController");

NotificationsController.defineAlias("model", "notifications");

NotificationsController.defineMethod("updateView", function () {
  if (!this.view) return;

  var bottom = 0;
  this.notifications.notifications = this.notifications.notifications.filter(function (notification) {
    var element = this.view.querySelector("[data-ica-notification-id='{0}']".format(notification.componentId));

    // Check existing element
    if (element) {
      element.style.bottom = bottom + "px";
    } else {
      // Create new view

      // Match controller
      var Controller;
      switch (notification.constructor) {
      case BasicNotification: Controller = BasicNotificationController; break;
      case ProgressNotification: Controller = ProgressNotificationController; break;
      case XHRProgressNotification: Controller = XHRProgressNotificationController; break;
      default:
        console.warn("Unhandled item:", notification.constructor);
        return false;
      }

      // Create view
      var fragment = Controller.createViewFragment();
      element = fragment.querySelector(".notification");
      element.style.bottom = bottom + "px";
      this.view.appendChild(fragment);
      new Controller(notification, element).componentOf = this;
    }

    bottom += element.offsetHeight + 8; // 16 px margin top & bottom

    return true;
  }.bind(this));
});
{'fraction_non_alphanumeric': 0.10982114841543772, 'fraction_numerical': 0.0031377470975839346, 'mean_word_length': 3.6472303206997085, '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': '5556321', 'n_tokens_mistral': 776, 'n_tokens_neox': 763, 'n_words': 173}