<commit_before>/******************************************************************************
 * Licensed under Apache License Version 2.0 - see LICENSE
 *****************************************************************************/

static PyObject *
PyIU_Monotone(PyObject *m,
              PyObject *args,
              PyObject *kwargs)
{
    static char *kwlist[] = {"iterable", "decreasing", "strict", NULL};

    PyObject *iterable, *iterator, *item, *last=NULL;
    int decreasing=0, strict=0, op, ok;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ii:all_monotone", kwlist,
                                     &iterable, &decreasing, &strict)) {
        return NULL;
    }
    iterator = PyObject_GetIter(iterable);
    if (iterator == NULL) {
        goto Fail;
    }
    op = decreasing ? (strict ? Py_GT : Py_GE) : (strict ? Py_LT : Py_LE);

    while ( (item = Py_TYPE(iterator)->tp_iternext(iterator)) ) {
        if (last == NULL) {
            last = item;
            continue;
        }
        ok = PyObject_RichCompareBool(last, item, op);
        Py_DECREF(last);
        last = item;
        if (ok == 0) {
            goto Found;
        } else if (ok == -1) {
            goto Fail;
        }
    }

    Py_XDECREF(iterator);
    Py_XDECREF(last);

    if (PyErr_Occurred()) {
        if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
            PyErr_Clear();
        } else {
            return NULL;
        }
    }
    Py_RETURN_TRUE;

Fail:
    Py_XDECREF(iterator);
    Py_XDECREF(last);
    return NULL;

Found:
    Py_XDECREF(iterator);
    Py_XDECREF(last);
    Py_RETURN_FALSE;
}<commit_msg>Remove some unnecessary NULL checks in all_montone.<commit_after>/******************************************************************************
 * Licensed under Apache License Version 2.0 - see LICENSE
 *****************************************************************************/

static PyObject *
PyIU_Monotone(PyObject *m,
              PyObject *args,
              PyObject *kwargs)
{
    static char *kwlist[] = {"iterable", "decreasing", "strict", NULL};

    PyObject *iterable, *iterator, *item, *last=NULL;
    int decreasing=0, strict=0, op, ok;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ii:all_monotone", kwlist,
                                     &iterable, &decreasing, &strict)) {
        return NULL;
    }
    iterator = PyObject_GetIter(iterable);
    if (iterator == NULL) {
        goto Fail;
    }
    op = decreasing ? (strict ? Py_GT : Py_GE) : (strict ? Py_LT : Py_LE);

    while ( (item = Py_TYPE(iterator)->tp_iternext(iterator)) ) {
        if (last == NULL) {
            last = item;
            continue;
        }
        ok = PyObject_RichCompareBool(last, item, op);
        Py_DECREF(last);
        last = item;
        if (ok == 0) {
            goto Found;
        } else if (ok == -1) {
            goto Fail;
        }
    }

    Py_DECREF(iterator);
    Py_XDECREF(last);

    if (PyErr_Occurred()) {
        if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
            PyErr_Clear();
        } else {
            return NULL;
        }
    }
    Py_RETURN_TRUE;

Fail:
    Py_XDECREF(iterator);
    Py_XDECREF(last);
    return NULL;

Found:
    Py_DECREF(iterator);
    Py_DECREF(last);
    Py_RETURN_FALSE;
}
{'fraction_non_alphanumeric': 0.20398912058023572, 'fraction_numerical': 0.003626473254759746, 'mean_word_length': 2.329979879275654, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3052031', 'n_tokens_mistral': 1013, 'n_tokens_neox': 1003, 'n_words': 218}