<commit_before>'use strict'

function EntryBuffer (maxLength) {
  this.buffer = []
  this.maxLength = maxLength || false
}

EntryBuffer.prototype.add = function (entry) {
  if (this.maxLength === false || this.buffer.length < this.maxLength) {
    this.buffer.push(entry)
  }
}

EntryBuffer.prototype.drain = function (callback) {
  this.buffer.reduceRight(function (buffer, entry) {
    buffer.splice(-1)

    if (callback) callback(entry)

    return buffer
  }, this.buffer)
}

EntryBuffer.prototype.length = function () {
  return this.buffer.length
}

module.exports = EntryBuffer
<commit_msg>optimized drainage<commit_after>'use strict'

function EntryBuffer (maxLength) {
  this.buffer = []
  this.maxLength = maxLength || false
}

EntryBuffer.prototype.add = function (entry) {
  if (this.maxLength === false || this.buffer.length < this.maxLength) {
    this.buffer.push(entry)
  }
}

EntryBuffer.prototype.drain = function (callback) {
  if (callback) {
    var i = this.buffer.length

    while (i--) {
      callback(this.buffer[i])
    }
  }

  this.buffer = []
}

EntryBuffer.prototype.length = function () {
  return this.buffer.length
}

module.exports = EntryBuffer

{'fraction_non_alphanumeric': 0.13609467455621302, 'fraction_numerical': 0.0008453085376162299, 'mean_word_length': 3.6431372549019607, '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': '2793620', 'n_tokens_mistral': 383, 'n_tokens_neox': 378, 'n_words': 74}