<commit_before>// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

'use strict';

base.exportTo('base', function() {
  var pendingPreAFs = [];
  var pendingRAFs = [];
  var currentRAFDispatchList = undefined;

  var rafScheduled = false;
  function scheduleRAF() {
    if (rafScheduled)
      return;
    rafScheduled = true;
    window.webkitRequestAnimationFrame(processRequests);
  }

  function processRequests() {
    rafScheduled = false;
    var currentPreAFs = pendingPreAFs;
    var currentRAFs = pendingRAFs;
    pendingPreAFs = [];
    pendingRAFs = [];
    for (var i = 0; i < pendingPreAFs; i++)
      this.pendingPreAFs.callback.call(pendingPreAFs.context);

    currentRAFDispatchList = currentRAFs;
    while (currentRAFDispatchList.length > 0) {
      var task = currentRAFDispatchList.shift();
      try {
        task.callback.call(task.context);
      } catch (e) {
        if (e.message)
          console.error(e.message, e.stack);
        else
          console.error(e);
      }
    }
    currentRAFDispatchList = undefined;
  }

  function requestPreAnimationFrame(callback, opt_this) {
    scheduleRAF();
    pendingRAFs.push({
      callback: callback,
      context: opt_this || window});
  }

  function requestAnimationFrameInThisFrameIfPossible(callback, opt_this) {
    if (!currentRAFDispatchList) {
      requestAnimationFrame(callback, opt_this);
      return;
    }
    currentRAFDispatchList.push({
      callback: callback,
      context: opt_this || window});
    return;
  }

  function requestAnimationFrame(callback, opt_this) {
    scheduleRAF();
    pendingRAFs.push({
      callback: callback,
      context: opt_this || window});
  }
  return {
    requestPreAnimationFrame: requestPreAnimationFrame,
    requestAnimationFrame: requestAnimationFrame,<commit_msg>More rAF fixes<commit_after>// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

'use strict';

base.exportTo('base', function() {
  var pendingPreAFs = [];
  var pendingRAFs = [];
  var currentRAFDispatchList = undefined;

  var rafScheduled = false;
  function scheduleRAF() {
    if (rafScheduled)
      return;
    rafScheduled = true;
    window.webkitRequestAnimationFrame(processRequests);
  }

  function runTask(task) {
    try {
      task.callback.call(task.context);
    } catch (e) {
      if (e.message)
        console.error(e.message, e.stack);
      else
        console.error(e);
    }
  }

  function processRequests() {
    rafScheduled = false;

    var currentPreAFs = pendingPreAFs;
    currentRAFDispatchList = pendingRAFs;
    pendingPreAFs = [];
    pendingRAFs = [];
    for (var i = 0; i < currentPreAFs.length; i++)
      runTask(currentPreAFs[i]);

    while (currentRAFDispatchList.length > 0)
      runTask(currentRAFDispatchList.shift());
    currentRAFDispatchList = undefined;
  }

  function requestPreAnimationFrame(callback, opt_this) {
    scheduleRAF();
    pendingPreAFs.push({
      callback: callback,
      context: opt_this || window});
  }

  function requestAnimationFrameInThisFrameIfPossible(callback, opt_this) {
    if (!currentRAFDispatchList) {
      requestAnimationFrame(callback, opt_this);
      return;
    }
    currentRAFDispatchList.push({
      callback: callback,
      context: opt_this || window});
    return;
  }

  function requestAnimationFrame(callback, opt_this) {
    scheduleRAF();
    pendingRAFs.push({
      callback: callback,
      context: opt_this || window});
  }
  return {
    requestPreAnimationFrame: requestPreAnimationFrame,
    requestAnimationFrame: requestAnimationFrame,
{'fraction_non_alphanumeric': 0.10252365930599369, 'fraction_numerical': 0.0031545741324921135, 'mean_word_length': 3.223085460599334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7100889', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1099, 'n_words': 260}