Patchwork dirs: add comment about _PyBytes_Resize

login
register
mail settings
Submitter Gregory Szorc
Date Oct. 13, 2016, 8:59 a.m.
Message ID <27e00e6352ceadb48c11.1476349172@gps-mbp.local>
Download mbox | patch
Permalink /patch/17049/
State Accepted
Headers show

Comments

Gregory Szorc - Oct. 13, 2016, 8:59 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1476349169 -7200
#      Thu Oct 13 10:59:29 2016 +0200
# Node ID 27e00e6352ceadb48c11c6f5902093a26d58f569
# Parent  733fb9f7bc92c694ba6bededaeb93206528c0bcd
dirs: add comment about _PyBytes_Resize

So readers have a canonical function to compare this code to.
Pierre-Yves David - Oct. 13, 2016, 9:05 a.m.
On 10/13/2016 10:59 AM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1476349169 -7200
> #      Thu Oct 13 10:59:29 2016 +0200
> # Node ID 27e00e6352ceadb48c11c6f5902093a26d58f569
> # Parent  733fb9f7bc92c694ba6bededaeb93206528c0bcd
> dirs: add comment about _PyBytes_Resize
>
> So readers have a canonical function to compare this code to.

Sure, pushed, thanks.

Cheers,

Patch

diff --git a/mercurial/dirs.c b/mercurial/dirs.c
--- a/mercurial/dirs.c
+++ b/mercurial/dirs.c
@@ -58,9 +58,10 @@  static int _addpath(PyObject *dirs, PyOb
 	* implementation details. We also commit violations of the Python
 	* "protocol" such as mutating immutable objects. But since we only
 	* mutate objects created in this function or in other well-defined
 	* locations, the references are known so these violations should go
-	* unnoticed. */
+	* unnoticed. The code for adjusting the length of a PyBytesObject is
+	* essentially a minimal version of _PyBytes_Resize. */
 	while ((pos = _finddir(cpath, pos - 1)) != -1) {
 		PyObject *val;
 
 		/* It's likely that every prefix already has an entry