<commit_before>import React from "react";
import classnames from "classnames";
import {Input} from "react-bootstrap";


class SearchBox extends React.Component {
    handleClear = () => {
        const {actions, collection, params} = this.props;
        const {router} = this.context;

        const query = collection.get("query").withMutations((map) => {
            map.set("page", 1);
            map.set("search", "");
        });

        actions.fetchCollection({collection, query});
        router.push(collection.appUrl(params));
    };

    handleSubmit = (evnt) => {
        const {actions, collection, params} = this.props;
        const {router} = this.context;
        const query = collection.get("query").set("page", 1);

        evnt.preventDefault();
        actions.fetchCollection({collection, query});
        router.replace(collection.appUrl(params));
    };

    handleChange = (evnt) => {
        const {actions, collection} = this.props;
        const query = collection.get("query").set("search", evnt.target.value);

        actions.updateCollectionQuery({collection, query});
    };

    render() {
        const {autoFocus = false, collection} = this.props;
        const search = collection.query.get("search");

        const submitButton = classnames({
            "btn": true,
            "btn-default": true,
            "hide": search.length !== 0
        });

        const clearButton = classnames({
            "btn": true,
            "btn-default": true,<commit_msg>Performance improvement<commit_after>import React from "react";
import classnames from "classnames";
import {Input} from "react-bootstrap";


class SearchBox extends React.Component {
    constructor(props) {
        super(props);
        const {collection} = props;
        this.state = {query: collection.get("query")};
    }

    handleClear = () => {
        const {actions, collection, params} = this.props;
        const {router} = this.context;
        let {query} = this.state;

        query = query.withMutations((map) => {
            map.set("page", 1);
            map.set("search", "");
        });

        actions.fetchCollection({collection, query});
        router.push(collection.appUrl(params));
    };

    handleSubmit = (evnt) => {
        const {actions, collection, params} = this.props;
        const {router} = this.context;
        let {query} = this.state;

        query = query.set("page", 1);
        evnt.preventDefault();
        actions.fetchCollection({collection, query});
        router.replace(collection.appUrl(params));
    };

    handleChange = (evnt) => {
        let {query} = this.state;
        query = query.set("search", evnt.target.value);
        this.setState({query});
    };

    render() {
        const {autoFocus = false} = this.props;
        const {query} = this.state;
        const search = query.get("search");

        const submitButton = classnames({
            "btn": true,
            "btn-default": true,
            "hide": search.length !== 0
        });

        const clearButton = classnames({
            "btn": true,
            "btn-default": true,
{'fraction_non_alphanumeric': 0.14755669115298628, 'fraction_numerical': 0.0019163206643244969, 'mean_word_length': 2.2933753943217665, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 11, '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': '3940448', 'n_tokens_mistral': 862, 'n_tokens_neox': 839, 'n_words': 191}