A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2015-July/140665.html below:

[Python-Dev] cpython: Minor bit of factoring-out common code.

[Python-Dev] cpython: Minor bit of factoring-out common code. [Python-Dev] cpython: Minor bit of factoring-out common code.Serhiy Storchaka storchaka at gmail.com
Tue Jul 7 09:19:37 CEST 2015
On 07.07.15 05:08, raymond.hettinger wrote:
> https://hg.python.org/cpython/rev/5088f2cd6293
> changeset:   96866:5088f2cd6293
> user:        Raymond Hettinger <python at rcn.com>
> date:        Mon Jul 06 19:08:49 2015 -0700
> summary:
>    Minor bit of factoring-out common code.

> +        if (rv < 0)
> +            goto error;
>           if (rv) {
> -            if (set_add_entry(result, key, hash)) {
> -                Py_DECREF(it);
> -                Py_DECREF(result);
> -                Py_DECREF(key);
> -                return NULL;
> -            }
> +            if (set_add_entry(result, key, hash))
> +                goto error;
>           }
>           Py_DECREF(key);
>       }

In tight loop it may be worth to rewrite the code

     if (rv < 0)
         goto error;
     if (rv) {
         expensive_operation();
     }
     // if (rv == 0) do nothing

in the form:

     if (rv) {
         if (rv < 0)
             goto error;
         expensive_operation();
     }

This looks less clear, but needs only one test in the case of rv == 0.


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4