<commit_before>var console;

(function($) {	

	/** What to call to run a function 'soon'. Normally setTimeout, but for syncronous mode we override so soon === now */
	var runSoon = window.setTimeout;
	
	/** Stores a count of definitions, so that we can sort identical selectors by definition order */
	var rulecount = 0;

	/** Utility to optionally display warning messages depending on level */
	var warn = function(message, level) {
		if (level <= $.concrete.warningLevel && console && console.log) { 
			console.warn(message);
			if (console.trace) console.trace();
		}
	}

   /** A property definition */
	$.property = function(options) {
		if (this instanceof $.property) this.options = options;
		else return new $.property(options);
	}
	$.extend($.property, {
		/**
		 * Strings for how to cast a value to a specific type. Used in some nasty meta-programming stuff below to try and
		 * keep property access as fast as possible
		 */
		casters: {
			'int': 'Math.round(parseFloat(v));',
			'float': 'parseFloat(v);',
			'string': '""+v;'
		},
		
		getter: function(options) {
			options = options || {};
			
			if (options.initial === undefined) return function(){ return this.d()[arguments.callee.pname] };
			
			var getter = function(){ 
				var d = this.d(); var k = arguments.callee.pname;
				return d.hasOwnProperty(k) ? d[k] : (d[k] = arguments.callee.initial);
			};
			var v = options.initial;
			getter.initial = options.restrict ? eval($.property.casters[options.restrict]) : v;
			
			return getter;
		},
		
		setter: function(options){
			options = options || {};
			if (options.restrict) {
				var restrict = options.restrict;
				return new Function('v', 'return this.d()[arguments.callee.pname] = ' + $.property.casters[options.restrict]);
			}
			
			return function(v){ return this.d()[arguments.callee.pname] = v; }
		}
	});
	$.extend($.property.prototype, {
		getter: function(){
			return $.property.getter(this.options);
		},
		setter: function(){
			return $.property.setter(this.options);
		}
	});

	var Rule = Base.extend({
		init: function(selector, name) {
			this.selector = selector;
			this.specifity = selector.specifity();
			this.important = 0;
			this.name = name;
			this.rulecount = rulecount++;
		}
	});
	
	Rule.compare = function(a, b) {
		var as = a.specifity, bs = b.specifity;
		
		return (a.important - b.important) ||
		       (as[0] - bs[0]) ||
		       (as[1] - bs[1]) ||
		       (as[2] - bs[2]) ||
		       (a.rulecount - b.rulecount) ;
	}

	$.fn._super = function(){
		var rv, i = this.length;
		while (i--) {
			var el = this[0];
			rv = el.f(el, arguments, el.i);
		}
		return rv;
	}

	var namespaces = {};

	var Namespace = Base.extend({
		init: function(name){
			if (name && !name.match(/^[A-Za-z0-9.]+$/)) warn('Concrete namespace '+name+' is not formatted as period seperated identifiers', $.concrete.WARN_LEVEL_BESTPRACTISE);
			name = name || '__base';
			
			this.name = name;
			this.store = {};
			
			namespaces[name] = this;
			
			if (name == "__base") {
				this.injectee = $.fn
				this.$ = $;
			}
			else {
				// We're in a namespace, so we build a Class that subclasses the jQuery Object Class to inject namespace functions into
				var subfn = function(jq){
					this.selector = jq.selector; this.context = jq.context; this.setArray($.makeArray(jq));
				}
				this.injectee = subfn.prototype = new $();
				
				// And then we provide an overriding $ that returns objects of our new Class, and an overriding pushStack to catch further selection building
				this.$ = function() {
					return new subfn($.apply(window, arguments));
				}
				this.injectee.pushStack = function(){
					return new subfn($.fn.pushStack.apply(this, arguments));
				}
				
				// Copy static functions through from $ to this.$ so e.g. $.ajax still works
				// @bug, @cantfix: Any class functions added to $ after this call won't get mirrored through 
				$.extend(this.$, $);
				
				// We override concrete to inject the name of this namespace when defining blocks inside this namespace
				var concrete_wrapper = this.injectee.concrete = function() {
					var args = arguments;
					
					if (!args[0] || typeof args[0] != 'string') { args = $.makeArray(args); args.unshift(name); }
					else if (args[0].charAt(0) != '.') args[0] = name+'.'+args[0];
					<commit_msg>Change the namespace-binding $ and $.pushStack overrides to be _much_ faster, at the expense of clarity and (possibly) forward-compatibility<commit_after>var console;

(function($) {	

	/** What to call to run a function 'soon'. Normally setTimeout, but for syncronous mode we override so soon === now */
	var runSoon = window.setTimeout;
	
	/** Stores a count of definitions, so that we can sort identical selectors by definition order */
	var rulecount = 0;

	/** Utility to optionally display warning messages depending on level */
	var warn = function(message, level) {
		if (level <= $.concrete.warningLevel && console && console.log) { 
			console.warn(message);
			if (console.trace) console.trace();
		}
	}

   /** A property definition */
	$.property = function(options) {
		if (this instanceof $.property) this.options = options;
		else return new $.property(options);
	}
	$.extend($.property, {
		/**
		 * Strings for how to cast a value to a specific type. Used in some nasty meta-programming stuff below to try and
		 * keep property access as fast as possible
		 */
		casters: {
			'int': 'Math.round(parseFloat(v));',
			'float': 'parseFloat(v);',
			'string': '""+v;'
		},
		
		getter: function(options) {
			options = options || {};
			
			if (options.initial === undefined) return function(){ return this.d()[arguments.callee.pname] };
			
			var getter = function(){ 
				var d = this.d(); var k = arguments.callee.pname;
				return d.hasOwnProperty(k) ? d[k] : (d[k] = arguments.callee.initial);
			};
			var v = options.initial;
			getter.initial = options.restrict ? eval($.property.casters[options.restrict]) : v;
			
			return getter;
		},
		
		setter: function(options){
			options = options || {};
			if (options.restrict) {
				var restrict = options.restrict;
				return new Function('v', 'return this.d()[arguments.callee.pname] = ' + $.property.casters[options.restrict]);
			}
			
			return function(v){ return this.d()[arguments.callee.pname] = v; }
		}
	});
	$.extend($.property.prototype, {
		getter: function(){
			return $.property.getter(this.options);
		},
		setter: function(){
			return $.property.setter(this.options);
		}
	});

	var Rule = Base.extend({
		init: function(selector, name) {
			this.selector = selector;
			this.specifity = selector.specifity();
			this.important = 0;
			this.name = name;
			this.rulecount = rulecount++;
		}
	});
	
	Rule.compare = function(a, b) {
		var as = a.specifity, bs = b.specifity;
		
		return (a.important - b.important) ||
		       (as[0] - bs[0]) ||
		       (as[1] - bs[1]) ||
		       (as[2] - bs[2]) ||
		       (a.rulecount - b.rulecount) ;
	}

	$.fn._super = function(){
		var rv, i = this.length;
		while (i--) {
			var el = this[0];
			rv = el.f(el, arguments, el.i);
		}
		return rv;
	}

	var namespaces = {};

	var Namespace = Base.extend({
		init: function(name){
			if (name && !name.match(/^[A-Za-z0-9.]+$/)) warn('Concrete namespace '+name+' is not formatted as period seperated identifiers', $.concrete.WARN_LEVEL_BESTPRACTISE);
			name = name || '__base';
			
			this.name = name;
			this.store = {};
			
			namespaces[name] = this;
			
			if (name == "__base") {
				this.injectee = $.fn
				this.$ = $;
			}
			else {
				// We're in a namespace, so we build a Class that subclasses the jQuery Object Class to inject namespace functions into
				var subfn = function(jq){
					this.selector = jq.selector; this.context = jq.context; this.setArray($.makeArray(jq));
				}
				this.injectee = subfn.prototype = new $();
				
				// And then we provide an overriding $ that returns objects of our new Class, and an overriding pushStack to catch further selection building
				var bound$ = this.$ = function(a) {
					// Try the simple way first
					var jq = $.fn.init.apply(new subfn(), arguments);
					if (jq instanceof subfn) return jq;
					
					// That didn't return a bound object, so now we need to copy it
					var rv = new subfn();
					rv.selector = jq.selector; rv.context = jq.context; var i = rv.length = jq.length;
					while (i--) rv[i] = jq[i];
					return rv;
				}
				this.injectee.pushStack = function(elems, name, selector){
					var ret = bound$(elems);

					// Add the old object onto the stack (as a reference)
					ret.prevObject = this;
					ret.context = this.context;
					
					if ( name === "find" ) ret.selector = this.selector + (this.selector ? " " : "") + selector;
					else if ( name )       ret.selector = this.selector + "." + name + "(" + selector + ")";
					
					// Return the newly-formed element set
					return ret;
				}
				
				// Copy static functions through from $ to this.$ so e.g. $.ajax still works
				// @bug, @cantfix: Any class functions added to $ after this call won't get mirrored through 
				$.extend(this.$, $);
				
				// We override concrete to inject the name of this namespace when defining blocks inside this namespace
				var concrete_wrapper = this.injectee.concrete = function() {
					var args = arguments;
					
					if (!args[0] || typeof args[0] != 'string') { args = $.makeArray(args); args.unshift(name); }
					else if (args[0].charAt(0) != '.') args[0] = name+'.'+args[0];
					
{'fraction_non_alphanumeric': 0.15107458912768648, 'fraction_numerical': 0.0035819637589549094, 'mean_word_length': 2.8937653814602133, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1643768', 'n_tokens_mistral': 3602, 'n_tokens_neox': 2976, 'n_words': 888}