<commit_before>(function () {
	var ns = $.namespace("pskl.model");
	
	ns.Frame = function (pixels) {
		this.pixels = pixels;
		this.previousStates = [this._clonePixels()];
		this.stateIndex = 0;
	};

	ns.Frame.createEmpty = function (width, height) {
		var pixels = []; //new Array(width);
		for (var columnIndex=0; columnIndex < width; columnIndex++) {
			var columnArray = [];
			for(var heightIndex = 0; heightIndex < height; heightIndex++) {
				columnArray.push(Constants.TRANSPARENT_COLOR);
			}
			pixels[columnIndex] = columnArray;
    	}
		return new ns.Frame(pixels);
	};

	ns.Frame.createEmptyFromFrame = function (frame) {
		return ns.Frame.createEmpty(frame.getWidth(), frame.getHeight());
	};

	ns.Frame.prototype.clone = function () {
		return new ns.Frame(this._clonePixels());
	};

	ns.Frame.prototype._clonePixels = function () {
		var pixels = [];
		for (var col = 0 ; col < this.getWidth() ; col++) {
			pixels[col] = this.pixels[col].slice(0 , this.getHeight());
		}
		return pixels;
	};

	ns.Frame.prototype.serialize = function () {
		return JSON.stringify(this.pixels);
	};

	ns.Frame.prototype.setPixel = function (col, row, color) {
		this.pixels[col][row] = color;
	};

	ns.Frame.prototype.getPixel = function (col, row) {
		return this.pixels[col][row];
	};

	ns.Frame.prototype.getWidth = function () {
		return this.pixels.length;
	};

	ns.Frame.prototype.getHeight = function () {
		return this.pixels[0].length;
	};

	ns.Frame.prototype.containsPixel = function (col, row) {
		return col >= 0 && row >= 0 && col < this.pixels.length && row < this.pixels[0].length;
	};

	ns.Frame.prototype.saveState = function () {
		// remove all states past current state
		this.previousStates.length = this.stateIndex + 1;
		// push new state
		this.previousStates.push(this._clonePixels());
		// set the stateIndex to latest saved state
		this.stateIndex = this.previousStates.length - 1;
	};

	ns.Frame.prototype.loadPreviousState = function () {
		if (this.stateIndex > 0) {
			this.stateIndex--;
			this.pixels = this.previousStates[this.stateIndex];
		}
	};

	ns.Frame.prototype.loadNextState = function () {
		if (this.stateIndex < this.previousStates.length - 1) {
			this.stateIndex++;
			this.pixels = this.previousStates[this.stateIndex];
		}	
	};
})();<commit_msg>Fixed undo/redo bug<commit_after>(function () {
	var ns = $.namespace("pskl.model");
	
	ns.Frame = function (pixels) {
		this.pixels = pixels;
		this.previousStates = [this.getPixels()];
		this.stateIndex = 0;
	};

	ns.Frame.createEmpty = function (width, height) {
		var pixels = []; //new Array(width);
		for (var columnIndex=0; columnIndex < width; columnIndex++) {
			var columnArray = [];
			for(var heightIndex = 0; heightIndex < height; heightIndex++) {
				columnArray.push(Constants.TRANSPARENT_COLOR);
			}
			pixels[columnIndex] = columnArray;
    	}
		return new ns.Frame(pixels);
	};

	ns.Frame.createEmptyFromFrame = function (frame) {
		return ns.Frame.createEmpty(frame.getWidth(), frame.getHeight());
	};

	ns.Frame.prototype.clone = function () {
		return new ns.Frame(this._clonePixels());
	};

	/**
	 * Returns a copy of the pixels used by the frame
	 */
	ns.Frame.prototype.getPixels = function () {
		return this.clonePixels_(this.pixels)
	};

	/**
	 * Copies the passed pixels into the frame.
	 */
	ns.Frame.prototype.setPixels = function (pixels) {
		this.pixels = this.clonePixels_(pixels);
	};

	/**
	 * Clone a set of pixels. Should be static utility method
	 * @private
	 */
	ns.Frame.prototype.clonePixels_ = function (pixels) {
		var clonedPixels = [];
		for (var col = 0 ; col < pixels.length ; col++) {
			clonedPixels[col] = pixels[col].slice(0 , this.getHeight());
		}
		return clonedPixels;
	};

	ns.Frame.prototype.serialize = function () {
		return JSON.stringify(this.pixels);
	};

	ns.Frame.prototype.setPixel = function (col, row, color) {
		this.pixels[col][row] = color;
	};

	ns.Frame.prototype.getPixel = function (col, row) {
		return this.pixels[col][row];
	};

	ns.Frame.prototype.getWidth = function () {
		return this.pixels.length;
	};

	ns.Frame.prototype.getHeight = function () {
		return this.pixels[0].length;
	};

	ns.Frame.prototype.containsPixel = function (col, row) {
		return col >= 0 && row >= 0 && col < this.pixels.length && row < this.pixels[0].length;
	};

	ns.Frame.prototype.saveState = function () {
		// remove all states past current state
		this.previousStates.length = this.stateIndex + 1;
		// push new state
		this.previousStates.push(this.getPixels());
		// set the stateIndex to latest saved state
		this.stateIndex = this.previousStates.length - 1;
	};

	ns.Frame.prototype.loadPreviousState = function () {
		if (this.stateIndex > 0) {
			this.stateIndex--;
			this.setPixels(this.previousStates[this.stateIndex]);
		}
	};

	ns.Frame.prototype.loadNextState = function () {
		if (this.stateIndex < this.previousStates.length - 1) {
			this.stateIndex++;
			this.setPixels(this.previousStates[this.stateIndex]);
		}	
	};
})();
{'fraction_non_alphanumeric': 0.1568627450980392, 'fraction_numerical': 0.005202080832332933, 'mean_word_length': 3.641597028783658, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 9, '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': '7274091', 'n_tokens_mistral': 1818, 'n_tokens_neox': 1657, 'n_words': 334}