<commit_before>/*
==================================================================================================
  Core - JavaScript Foundation
  Copyright 2010-2012 <NAME>
--------------------------------------------------------------------------------------------------
  Based on the work of:
  Hogan.JS by Twitter, Inc.
  https://github.com/twitter/hogan.js
  Licensed under the Apache License, Version 2.0
  http://www.apache.org/licenses/LICENSE-2.0
==================================================================================================
*/

(function () 
{
	
	var rSlash = /\\/g;
	var rQuot = /\"/g;
	var rNewline =	/\n/g;
	var rCr = /\r/g;

	function esc(s) {
		return s.replace(rSlash, '\\\\').replace(rQuot, '\\\"').replace(rNewline, '\\n').replace(rCr, '\\r');
	}

	function chooseFieldAccessMethod(str) {
		return ~str.indexOf('.') ? 'getDotted' : 'get';
	}

	function walk(tree) 
	{
		var code = '';
		
		for (var i = 0, l = tree.length; i < l; i++) 
		{
			var tag = tree[i].tag;
			
			if (tag == '#') {
				code += section(tree[i].nodes, tree[i].name, chooseFieldAccessMethod(tree[i].name), tree[i].start, tree[i].end);
			} else if (tag == '^') {
				code += invertedSection(tree[i].nodes, tree[i].name, chooseFieldAccessMethod(tree[i].name));
			} else if (tag == '<' || tag == '>') {
				code += partial(tree[i]);
			} else if (tag == '{' || tag == '&') {
				code += tripleStache(tree[i].name, chooseFieldAccessMethod(tree[i].name));
			} else if (tag == '\n') {
				code += text('"\\n"' + (tree.length-1 == i ? '' : ' + i'));
			} else if (tag == '$') {
				code += variable(tree[i].name, chooseFieldAccessMethod(tree[i].name));
			} else if (tag == null) {
				code += text('"' + esc(tree[i]) + '"');
			}
		}
		
		return code;
	}

	function section(nodes, id, method, start, end) {
		return 'if(_.section(_.' + method + '("' + esc(id) + '",c,p,1),c,p,0,' + start + ',' + end + ')){_.rs(c,p,function(c,p,_){' + walk(nodes) + '});c.pop();}';
	}<commit_msg>Tweaked compiler<commit_after>/*
==================================================================================================
  Core - JavaScript Foundation
  Copyright 2010-2012 <NAME>
--------------------------------------------------------------------------------------------------
  Based on the work of:
  Hogan.JS by Twitter, Inc.
  https://github.com/twitter/hogan.js
  Licensed under the Apache License, Version 2.0
  http://www.apache.org/licenses/LICENSE-2.0
==================================================================================================
*/

(function () 
{
	
	var rSlash = /\\/g;
	var rQuot = /\"/g;
	var rNewline =	/\n/g;
	var rCr = /\r/g;

	function esc(s) {
		return s.replace(rSlash, '\\\\').replace(rQuot, '\\\"').replace(rNewline, '\\n').replace(rCr, '\\r');
	}

	function chooseAccessMethod(str) {
		return ~str.indexOf('.') ? 'getDotted' : 'get';
	}

	function walk(node) 
	{
		var code = '';
		var tag, name;
		
		for (var i = 0, l = node.length; i < l; i++) 
		{
			var current = node[i];
			var tag = current.tag;
			
			if (tag == null) 
			{
				code += text('"' + esc(current) + '"');
			}
			else
			{
				var name = current.name;
				
				if (tag == '#') {
					code += section(current.nodes, name, chooseAccessMethod(name), current.start, current.end);
				} else if (tag == '^') {
					code += invertedSection(current.nodes, name, chooseAccessMethod(name));
				} else if (tag == '<' || tag == '>') {
					code += partial(current);
				} else if (tag == '{' || tag == '&') {
					code += tripleStache(name, chooseAccessMethod(name));
				} else if (tag == '\n') {
					code += text('"\\n"' + (node.length-1 == i ? '' : ' + i'));
				} else if (tag == '$') {
					code += variable(name, chooseAccessMethod(name));
				}
			}
		}
		
		return code;
	}

	function section(nodes, id, method, start, end) {
		return 'if(_.section(_.' + method + '("' + esc(id) + '",c,p,1),c,p,0,' + start + ',' + end + ')){_.rs(c,p,function(c,p,_){' + walk(nodes) + '});c.pop();}';
	}
{'fraction_non_alphanumeric': 0.34505988023952094, 'fraction_numerical': 0.007984031936127744, 'mean_word_length': 2.7086031452358927, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '1648663', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1314, 'n_words': 282}