<commit_before>;(function(){

    var ov = this.Overload = function(argsOps, func) {
        argsOps = ov.convertArgsString(argsOps);
        return function(){
            return func.apply(this, ov.getCorrectArguments(arguments, argsOps));
        }
    };

    ov.convertArgsString = function(argsString) {
        argsString = argsString.split(',');

        var args = {
                length: argsString.length,
                requiredLength: 0
            },
            reg = /\{([^}]+)\}\s*(\[*\w*)/,
            match, types, argument,
            i, n;

        for(i = 0; i < argsString.length; i++) {
            match = argsString[i].match(reg);
            argument = {
                types:    [],
                mixed:    match[1] === '*',
                required: match[2].charAt(0) !== '['
            };

            args[i] = argument;

            if( argument.required ) args.requiredLength++;

            if( argument.mixed ) continue;

            types = match[1].split('|');
            for(n = 0; n < types.length; n++) {
                argument.types.push(types[n].toLowerCase());
            }
        }

        return args;
    };

    ov.isValidArgument = function(argument, option) {
        if( option.mixed ) return true;

        for(var i = 0; i < option.types.length; i++) {
            if( typeof argument === option.types[i] ) {
                return true;
            }
        }

        return false;
    };

    ov.getCorrectArguments = function(args, ops) {
        var correctArgs = new Array(ops.length),
            i;

        if( args.length === ops.length ) {
            for(i = 0; i < args.length; i++) {
                correctArgs[i] = args[i];
            }

            return correctArgs;
        }

        var argsForRequired = args.length,
            required = ops.requiredLength,
            n, argument, option;

        for(i = 0, n = 0; i < ops.length; i++) {
            option = ops[i];
            argument = args[n];
            if( option.required || (argsForRequired - 1 >= required && ov.isValidArgument(argument, option)) ) {
                correctArgs[i] = argument;
                n++;
                argsForRequired--;
                if( option.required ) required--;
            }
        }

        return correctArgs;
    };
<commit_msg>removed several for-loops cached regular expression<commit_after>;(function(){

    var ov = this.Overload = function(argsOps, func) {
        argsOps = ov.convertArgsString(argsOps);
        return function(){
            return func.apply(this, ov.getCorrectArguments(arguments, argsOps));
        };
    },
    reg = /\{([^}]+)\}\s*(\[*\w*)/,
    slice = [].slice;

    ov.convertArgsString = function(argsString) {
        argsString = argsString.split(',');

        var args = {
                length: argsString.length,
                requiredLength: 0
            },
            match, argument, i;

        for(i = 0; i < argsString.length; i++) {
            match = argsString[i].match(reg);
            argument = {
                types:    [],
                mixed:    match[1] === '*',
                required: match[2].charAt(0) !== '['
            };

            args[i] = argument;

            if( argument.required ) args.requiredLength++;

            if( argument.mixed ) continue;

            argument.types = match[1].toLowerCase().split('|');
        }

        return args;
    };

    ov.isValidArgument = function(argument, option) {
        return option.mixed || option.types.indexOf(typeof argument) > -1;
    };

    ov.getCorrectArguments = function(args, ops) {
        if( args.length === ops.length ) {
            return slice.call(args);
        }

        var correctArgs = new Array(ops.length),
            argsForRequired = args.length,
            required = ops.requiredLength,
            n, argument, option, i;

        for(i = 0, n = 0; i < ops.length; i++) {
            option = ops[i];
            argument = args[n];
            if( option.required || (argsForRequired - 1 >= required && ov.isValidArgument(argument, option)) ) {
                correctArgs[i] = argument;
                n++;
                argsForRequired--;
                if( option.required ) required--;
            }
        }

        return correctArgs;
    };

{'fraction_non_alphanumeric': 0.13955637707948243, 'fraction_numerical': 0.005083179297597043, 'mean_word_length': 1.4879310344827585, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 6, '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': '756158', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1165, 'n_words': 254}