<commit_before>var React = require('react');
var BadgeItem = require('./badgeitem');

var BadgeList = React.createClass({
    isMatch: function (badge) {
        var regexFilter = new RegExp(this.props.filterText, 'i');
        return regexFilter.test(badge.name) ||
            regexFilter.test(badge.title) ||
            regexFilter.test(badge.comment) ||
            regexFilter.test(badge.categoryTags) ||
            regexFilter.test(badge.createdAt.getFullYear());
    },
    processBadges: function (badge, index, badges) {
        if (!badge) {
            return;
        }
        var lastBadge = badges[index - 1],
            lastDate;
        if (lastBadge) {
            lastDate = lastBadge.createdAt;
        }
        if (this.props.filterText) {
            if (badge.isGroup) {
                if (this.isMatch(badge)) {
                    return (
                        <BadgeItem badges={badge} lastDate={lastDate} isDescending={this.props.isDescending} key={badge.id} />
                    );
                } else {
                    var i = 0,
                        len = badge.badges.length,
                        b;
                    while (i < len) {
                        b = badge.badges[i];
                        if (this.isMatch(b))
                            return (
                                <BadgeItem badges={badge} lastDate={lastDate} isDescending={this.props.isDescending} key={b.id} />
                            );
                        i++;
                    }
                }
            } else if (this.isMatch(badge)) {
                return (
                    <BadgeItem badges={badge} lastDate={lastDate} isDescending={this.props.isDescending} key={badge.id} />
                );
            }
        } else {
            return (
                <BadgeItem badges={badge} lastDate={lastDate} isDescending={this.props.isDescending} key={badge.id} />
            );
        }
    },
    render: function() {
        var directionIcon = 'fa ' + (this.props.isDescending ? 'fa-caret-down' : 'fa-caret-up');
        return (
            <div>
            <div className="sortContainer">
            By Creation Date:
            <div className="direction" onClick={this.props.switchDirection}>
            <i className={directionIcon} /> {this.props.isDescending ? 'Descending' : 'Ascending'}
            </div>
            </div>
            <div className="badgeList">
            {this.props.badges.map(this.processBadges)}
            </div>
            </div>
        );
    }
});

module.exports = BadgeList;<commit_msg>improve search performance slightly<commit_after>var React = require('react');
var BadgeItem = require('./badgeitem');

var BadgeList = React.createClass({
    isMatch: function (badge) {
        var regexFilter = new RegExp(this.props.filterText, 'i');
        return regexFilter.test(badge.name) ||
            regexFilter.test(badge.title) ||
            regexFilter.test(badge.comment) ||
            regexFilter.test(badge.categoryTags) ||
            regexFilter.test(badge.createdAt.getFullYear());
    },
    queryBadges: function (badge, index, badges) {
        if (badge.isGroup) {
            if (this.isMatch(badge)) {
                return true;
            } else {
                var i = 0,
                    len = badge.badges.length,
                    b;
                while (i < len) {
                    b = badge.badges[i];
                    if (this.isMatch(b))
                        return true;
                    i++;
                }
            }
        } else if (this.isMatch(badge)) {
            return true;
        }
    },
    processBadges: function (badge, index, badges) {
        var lastBadge = badges[index - 1],
            lastDate;
        if (lastBadge) {
            lastDate = lastBadge.createdAt;
        }
        return (
            <BadgeItem badges={badge} lastDate={lastDate} isDescending={this.props.isDescending} key={badge.id} />
        );
    },
    render: function() {
        var directionIcon = 'fa ' + (this.props.isDescending ? 'fa-caret-down' : 'fa-caret-up');
        return (
            <div>
            <div className="sortContainer">
            By Creation Date:
            <div className="direction" onClick={this.props.switchDirection}>
            <i className={directionIcon} /> {this.props.isDescending ? 'Descending' : 'Ascending'}
            </div>
            </div>
            <div className="badgeList">
            {this.props.filterText ? this.props.badges.filter(this.queryBadges).map(this.processBadges) : this.props.badges.map(this.processBadges)}
    </div>
    </div>
    );
}
                                  });

module.exports = BadgeList;
{'fraction_non_alphanumeric': 0.12570948076518815, 'fraction_numerical': 0.0008408660920748371, 'mean_word_length': 1.4755463059313216, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7278084', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1321, 'n_words': 233}