<commit_before>//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Creates color key
//------------------------------------------------------------------------------
d3plus.ui.legend = function(vars) {

  var key_display = true,
      square_size = 0,
      key = vars.color.value || vars.id.value
    , colorName = vars.color.value || "d3plus_color"

  if (!vars.small && vars.legend.value && key) {

    if (!vars.color.scale) {

      if ( vars.dev.value ) d3plus.console.time("grouping data by colors")

      if ( vars.nodes.value && d3plus.visualization[vars.type.value].requirements.indexOf("nodes") >= 0 ) {
        var data = vars.nodes.restriced || vars.nodes.value
        if ( vars.data.app.length ) {
          for ( var i = 0 ; i < data.length ; i++ ) {
            var appData = vars.data.app.filter(function(a){
              return a[vars.id.value] === data[i][vars.id.value]
            })
            if (appData.length) {
              data[i] = d3plus.object.merge(data[i],appData[0])
            }
          }
        }
      }
      else {
        var data = d3plus.util.copy(vars.data.app)
      }

      for ( var z = 0 ; z < data.length ; z++ ) {

        d = data[z]

        for ( var i = 0 ; i < vars.id.nesting.length ; i++ ) {

          var colorKey = vars.id.nesting[i]

          if ( !(colorKey in d) ) {
            var nextKey = vars.id.nesting[ i + 1 ]
            d[colorKey] = d3plus.variable.value( vars , d[nextKey] , colorKey , nextKey )
          }

        }

      }

      var colorFunction = function( d ){
            return d3plus.variable.color( vars , d , vars.id.nesting[colorDepth] )
          }

      for ( var i = 0 ; i < vars.id.nesting.length ; i++ ) {

        var colorDepth = i
          , colorKey   = vars.id.nesting[i]

        var uniqueIDs = d3plus.util.uniques( data , colorKey )<commit_msg>removed unnecessary copying of data<commit_after>//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Creates color key
//------------------------------------------------------------------------------
d3plus.ui.legend = function(vars) {

  var key_display = true,
      square_size = 0,
      key = vars.color.value || vars.id.value
    , colorName = vars.color.value || "d3plus_color"

  if (!vars.small && vars.legend.value && key) {

    if (!vars.color.scale) {

      if ( vars.dev.value ) d3plus.console.time("grouping data by colors")

      if ( vars.nodes.value && d3plus.visualization[vars.type.value].requirements.indexOf("nodes") >= 0 ) {
        var data = vars.nodes.restriced || vars.nodes.value
        if ( vars.data.app.length ) {
          for ( var i = 0 ; i < data.length ; i++ ) {
            var appData = vars.data.app.filter(function(a){
              return a[vars.id.value] === data[i][vars.id.value]
            })
            if (appData.length) {
              data[i] = d3plus.object.merge(data[i],appData[0])
            }
          }
        }
      }
      else {
        var data = vars.data.app
      }

      for ( var z = 0 ; z < data.length ; z++ ) {

        d = data[z]

        for ( var i = 0 ; i < vars.id.nesting.length ; i++ ) {

          var colorKey = vars.id.nesting[i]

          if ( !(colorKey in d) ) {
            var nextKey = vars.id.nesting[ i + 1 ]
            d[colorKey] = d3plus.variable.value( vars , d[nextKey] , colorKey , nextKey )
          }

        }

      }

      var colorFunction = function( d ){
            return d3plus.variable.color( vars , d , vars.id.nesting[colorDepth] )
          }

      for ( var i = 0 ; i < vars.id.nesting.length ; i++ ) {

        var colorDepth = i
          , colorKey   = vars.id.nesting[i]

        var uniqueIDs = d3plus.util.uniques( data , colorKey )
{'fraction_non_alphanumeric': 0.2150026413100898, 'fraction_numerical': 0.008716323296354992, 'mean_word_length': 1.6427076064200976, 'pattern_counts': {'":': 0, '<': 11, '<?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': '5176684', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1184, 'n_words': 244}