<commit_before>/*
 *    (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*global d3:false*/

var statusColorMap = {
  "success": "LightGreen",
  "fail": "Crimson",
  "skip": "DodgerBlue"
};

var binaryMinIndex = function(min, array, func) {
  "use strict";

  var left = 0;
  var right = array.length - 1;

  while (left < right) {
    var mid = Math.floor((left + right) / 2);

    if (min < func(array[mid])) {
      right = mid - 1;
    } else if (min > func(array[mid])) {
      left = mid + 1;
    } else {
      right = mid;
    }
  }

  if (func(array[left]) <= min) {
    return left;
  } else {
    return left - 1;
  }
};

var binaryMaxIndex = function(max, array, func) {
  "use strict";

  var left = 0;
  var right = array.length - 1;

  while (left < right) {
    var mid = Math.floor((left + right) / 2);

    if (max < func(array[mid])) {
      right = mid - 1;
    } else if (max > func(array[mid])) {
      left = mid + 1;
    } else {
      right = mid;
    }
  }

  if (func(array[right]) <= max) {
    return right + 1; // exclusive index
  } else {
    return right;
  }
};

var parseWorker = function(tags) {
  "use strict";

  for (var i = 0; i < tags.length; i++) {
    if (!tags[i].startsWith("worker")) {
      continue;
    }

    return parseInt(tags[i].split("-")[1]);
  }<commit_msg>Correct potential edge cast in binaryMinIndex and binaryMaxIndex when a search value is out of bounds.<commit_after>/*
 *    (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*global d3:false*/

var statusColorMap = {
  "success": "LightGreen",
  "fail": "Crimson",
  "skip": "DodgerBlue"
};

var binaryMinIndex = function(min, array, func) {
  "use strict";

  var left = 0;
  var right = array.length - 1;

  while (left < right) {
    var mid = Math.floor((left + right) / 2);

    if (min < func(array[mid])) {
      right = mid - 1;
    } else if (min > func(array[mid])) {
      left = mid + 1;
    } else {
      right = mid;
    }
  }

  if (left >= array.length) {
    return array.length - 1;
  } else if (func(array[left]) <= min) {
    return left;
  } else {
    return left - 1;
  }
};

var binaryMaxIndex = function(max, array, func) {
  "use strict";

  var left = 0;
  var right = array.length - 1;

  while (left < right) {
    var mid = Math.floor((left + right) / 2);

    if (max < func(array[mid])) {
      right = mid - 1;
    } else if (max > func(array[mid])) {
      left = mid + 1;
    } else {
      right = mid;
    }
  }

  if (right < 0) {
    return 0;
  } else if (func(array[right]) <= max) {
    return right + 1; // exclusive index
  } else {
    return right;
  }
};

var parseWorker = function(tags) {
  "use strict";

  for (var i = 0; i < tags.length; i++) {
    if (!tags[i].startsWith("worker")) {
      continue;
    }

    return parseInt(tags[i].split("-")[1]);
  }
{'fraction_non_alphanumeric': 0.1401963251950667, 'fraction_numerical': 0.012333249433677322, 'mean_word_length': 2.6325411334552102, 'pattern_counts': {'":': 6, '<': 18, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5371619', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1284, 'n_words': 446}