<commit_before>Werld.Views.Screen = Backbone.View.extend({
  initialize: function() {
    this.model.bind('change:coordinates', this.draw, this);
    this.createTileViews();
  },
  createTileViews: function() {
    this.tileViews = new Array();
    var self = this;
    this.model.get('map').get('tiles').forEach(function(tileArray) {
      tileArray.forEach(function(tile) {
        self.tileViews.push(new Werld.Views.Tile({ model: tile }));
      });
    });
  },
  draw: function() {
    var mapTiles = this.model.get('map').get('tiles');
    var screenCoordinatess = this.model.get('coordinates');

    for (var i = 0; i < this.model.get('width'); i++) {
      for (var j = 0; j < this.model.get('height'); j++) {
        var screenColumn = i + screenCoordinatess[0];
        var screenRow = j + screenCoordinatess[1];

        if (screenColumn > 0 && screenColumn < Werld.Config.WORLD_MAP_WIDTH &&
              screenRow > 0 && screenRow < Werld.Config.WORLD_MAP_HEIGHT) {
          // TODO: Get tile view from the tile views already instantiated.
          (new Werld.Views.Tile({
            model: mapTiles[screenColumn][screenRow]
          })).draw([i, j]);
        } else {
          Werld.canvas.context.fillStyle = 'black';
          Werld.canvas.context.fillRect(
            i * Werld.Config.PIXELS_PER_TILE,
            j * Werld.Config.PIXELS_PER_TILE,
            Werld.Config.PIXELS_PER_TILE,
            Werld.Config.PIXELS_PER_TILE
          );
        }
      }
    }
  }
});<commit_msg>Avoid creating views at runtime.<commit_after>Werld.Views.Screen = Backbone.View.extend({
  initialize: function() {
    this.model.bind('change:coordinates', this.draw, this);
    this.createMapTileViews();
  },
  createMapTileViews: function() {
    var mapTiles = this.model.get('map').get('tiles');

    this.mapTileViews = [];
    for (var i = 0; i < mapTiles.length; i++) {
      this.mapTileViews[i] = [];
      for (var j = 0; j < mapTiles[i].length; j++) {
        this.mapTileViews[i][j] = new Werld.Views.Tile({
          model: mapTiles[i][j]
        });
      }
    }
  },
  draw: function() {
    var mapTiles = this.model.get('map').get('tiles');
    var screenCoordinatess = this.model.get('coordinates');

    for (var i = 0; i < this.model.get('width'); i++) {
      for (var j = 0; j < this.model.get('height'); j++) {
        var screenColumn = i + screenCoordinatess[0];
        var screenRow = j + screenCoordinatess[1];

        if (screenColumn > 0 && screenColumn < Werld.Config.WORLD_MAP_WIDTH &&
              screenRow > 0 && screenRow < Werld.Config.WORLD_MAP_HEIGHT) {
          this.mapTileViews[screenColumn][screenRow].draw([i, j]);
        } else {
          Werld.canvas.context.fillStyle = 'black';
          Werld.canvas.context.fillRect(
            i * Werld.Config.PIXELS_PER_TILE,
            j * Werld.Config.PIXELS_PER_TILE,
            Werld.Config.PIXELS_PER_TILE,
            Werld.Config.PIXELS_PER_TILE
          );
        }
      }
    }
  }
});
{'fraction_non_alphanumeric': 0.15236194278110446, 'fraction_numerical': 0.004657351962741184, 'mean_word_length': 2.4015837104072397, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, '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': '6158765', 'n_tokens_mistral': 1025, 'n_tokens_neox': 1013, 'n_words': 176}