<commit_before>Travis.LimitedArray = Em.ArrayProxy.extend
  limit: 10
  isLoadedBinding: 'content.isLoaded'

  init: ->
    @_super.apply this, arguments

  arrangedContent: (->
    content = @get('content')
    if @get('disable')
      content
    else if content
      content.slice(0, @get('limit'))
  ).property('content', 'limit', 'disable')

  totalLength: (->
    @get('content.length')
  ).property('content.length')

  leftLength: (->
    totalLength = @get('totalLength')
    limit       = @get('limit')
    if totalLength > limit
      totalLength - limit
    else
      0
  ).property('totalLength', 'limit')

  isMore: (->
    @get('leftLength') > 0
  ).property('leftLength')

  showAll: ->
    @set 'limit', 1000000000
    @set 'disable', true

  contentArrayDidChange: (array, index, removedCount, addedCount) ->
    @_super.apply this, arguments

    return if @get('disable')

    limit  = @get 'limit'
    arrangedContent = @get('arrangedContent')
    length = arrangedContent.get 'length'

    if addedCount > 0 && length < limit
      addedObjects = array.slice(index, index + addedCount)
      for object in addedObjects
        arrangedContent.unshiftObject(object)

    if removedCount
      removedObjects = array.slice(index, index + removedCount);
      arrangedContent.removeObjects(removedObjects)

    if length > limit
      arrangedContent.replace(limit, length - limit)
    else if length < limit
      @set('arrangedContent', @get('content').slice(0, @get('limit')))
<commit_msg>Do not refresh entire LimitedArray if there is not such need<commit_after>Travis.LimitedArray = Em.ArrayProxy.extend
  limit: 10
  isLoadedBinding: 'content.isLoaded'

  init: ->
    @_super.apply this, arguments

  arrangedContent: (->
    content = @get('content')
    if @get('disable')
      content
    else if content
      content.slice(0, @get('limit'))
  ).property('content', 'limit', 'disable')

  totalLength: (->
    @get('content.length')
  ).property('content.length')

  leftLength: (->
    totalLength = @get('totalLength')
    limit       = @get('limit')
    if totalLength > limit
      totalLength - limit
    else
      0
  ).property('totalLength', 'limit')

  isMore: (->
    @get('leftLength') > 0
  ).property('leftLength')

  showAll: ->
    @set 'limit', 1000000000
    @set 'disable', true

  contentArrayDidChange: (array, index, removedCount, addedCount) ->
    @_super.apply this, arguments

    return if @get('disable')

    limit  = @get 'limit'
    arrangedContent = @get('arrangedContent')
    length = arrangedContent.get 'length'

    if addedCount > 0
      addedObjects = array.slice(index, index + addedCount)
      for object in addedObjects
        arrangedContent.unshiftObject(object)

    if removedCount
      removedObjects = array.slice(index, index + removedCount);
      arrangedContent.removeObjects(removedObjects)

    length = arrangedContent.get 'length'
    content = @get('content')

    if length > limit
      arrangedContent.replace(limit, length - limit)
    else if length < limit && content.get('length') > length
      count = limit - length
      while count > 0
        if next = content.find( (object) -> !arrangedContent.contains(object) )
          arrangedContent.unshiftObject(next)
        count -= 1

{'fraction_non_alphanumeric': 0.1292972315181016, 'fraction_numerical': 0.01064800730149072, 'mean_word_length': 3.11, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '4930732', 'n_tokens_mistral': 1000, 'n_tokens_neox': 963, 'n_words': 236}