<commit_before>(function(global){
  'use strict';
  var previous = [null];
  var handlers = [];
  var hashRegex = /#.*$/;

  var fireHandlers = function(fragment) {
    for (var i = 0; i<handlers.length; i++) {
      handlers[i](fragment);
    }
  };

  /**
   * Removes the given handler from the registered
   * handlers.
   *
   * @param {Function} handler
   */
  var off = function(handler) {
    var idx = handlers.indexOf(handler);
    if (idx !== -1) {
      handlers.splice(idx, 1);
    }
  };

  /**
   * Clears the array of registered handlers.
   */
  var clear = function() {
    handlers.length = 0;
  };

  /**
   * Mark the state as processed- if the hash is
   * changed to the identical state then no Stateless
   * handlers will be fired. You do not need to prefix
   * the state with a hashtag.
   *
   * @param {String} state
   */
  var skip = function(state) {
    previous[0] = '#' + state;
  };

  /**
   * Pull the current state from the URL, and
   * forcefully runs the handlers regardless
   * of whether the hash has changed.
   */
  var pull = function() {
    var fragment = window.location.hash.substr(1);
    fireHandlers(fragment);
    skip(fragment);
  };

  /**
   * Set the current hash fragment as the given
   * state. Note that it is not necessary to
   * preceed your strings with '#'.
   *
   * @param {String} state
   */
  var push = function(state) {
    window.location.hash = state;
  };

  /**
   * Replaces the current hash with the given state.
   * Does not push another entry into the browser
   * history.
   *
   * @param {String} state
   */
  var replace = function(state) {
    window.location.replace('#' + state);
  };

  /**
   * Register a Stateless handler. Handlers will
   * be passed the hash fragment after the hash
   * character.
   *
   * @param {Function} handler
   */
  var onChange = function(handler) {
    handlers.push(handler);
  };
  
  window.addEventListener('hashchange', function() {
    // Workaround for Firefox which automatically
    // decodes the hash fragment [bug:483304]
    var match = hashRegex.exec(window.location.href);
    if (match) {
      var hash = match[0];
      if (hash !== previous[0]) {
        var fragment = hash.substring(1);
        fireHandlers(fragment);
        skip(fragment);
      }
    }
  });<commit_msg>slightly more efficient matching function<commit_after>(function(global){
  'use strict';
  var previous = [null];
  var handlers = [];
  var hashRegex = /#.*$/;

  var fireHandlers = function(fragment) {
    for (var i = 0; i<handlers.length; i++) {
      handlers[i](fragment);
    }
  };

  /**
   * Removes the given handler from the registered
   * handlers.
   *
   * @param {Function} handler
   */
  var off = function(handler) {
    var idx = handlers.indexOf(handler);
    if (idx !== -1) {
      handlers.splice(idx, 1);
    }
  };

  /**
   * Clears the array of registered handlers.
   */
  var clear = function() {
    handlers.length = 0;
  };

  /**
   * Mark the state as processed- if the hash is
   * changed to the identical state then no Stateless
   * handlers will be fired. You do not need to prefix
   * the state with a hashtag.
   *
   * @param {String} state
   */
  var skip = function(state) {
    previous[0] = '#' + state;
  };

  /**
   * Pull the current state from the URL, and
   * forcefully runs the handlers regardless
   * of whether the hash has changed.
   */
  var pull = function() {
    var fragment = window.location.hash.substr(1);
    fireHandlers(fragment);
    skip(fragment);
  };

  /**
   * Set the current hash fragment as the given
   * state. Note that it is not necessary to
   * preceed your strings with '#'.
   *
   * @param {String} state
   */
  var push = function(state) {
    window.location.hash = state;
  };

  /**
   * Replaces the current hash with the given state.
   * Does not push another entry into the browser
   * history.
   *
   * @param {String} state
   */
  var replace = function(state) {
    window.location.replace('#' + state);
  };

  /**
   * Register a Stateless handler. Handlers will
   * be passed the hash fragment after the hash
   * character.
   *
   * @param {Function} handler
   */
  var onChange = function(handler) {
    handlers.push(handler);
  };
  
  window.addEventListener('hashchange', function() {
    // Workaround for Firefox which automatically
    // decodes the hash fragment [bug:483304]
    var match = hashRegex.exec(window.location.href) || '#';
    var hash = match[0];
    if (hash !== previous[0]) {
      var fragment = hash.substring(1);
      fireHandlers(fragment);
      skip(fragment);
    }
  });
{'fraction_non_alphanumeric': 0.1280120481927711, 'fraction_numerical': 0.006454388984509466, 'mean_word_length': 2.4876219054763693, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1818102', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1412, 'n_words': 448}