Patchwork parsers: narrow scope of a variable to be less confusing

login
register
mail settings
Submitter Bryan O'Sullivan
Date Dec. 13, 2015, 5:01 a.m.
Message ID <f9d7c5483dbb148a0895.1449982879@bryano-mbp.netgear.com>
Download mbox | patch
Permalink /patch/11999/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Bryan O'Sullivan - Dec. 13, 2015, 5:01 a.m.
# HG changeset patch
# User Bryan O'Sullivan <bos@serpentine.com>
# Date 1449982621 28800
#      Sat Dec 12 20:57:01 2015 -0800
# Node ID f9d7c5483dbb148a0895867a601f8d0920379be2
# Parent  7d1b0fa50a8f1f856104aa7afd60f54b736ae170
parsers: narrow scope of a variable to be less confusing
Yuya Nishihara - Dec. 13, 2015, 8:20 a.m.
On Sat, 12 Dec 2015 21:01:19 -0800, Bryan O'Sullivan wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bos@serpentine.com>
> # Date 1449982621 28800
> #      Sat Dec 12 20:57:01 2015 -0800
> # Node ID f9d7c5483dbb148a0895867a601f8d0920379be2
> # Parent  7d1b0fa50a8f1f856104aa7afd60f54b736ae170
> parsers: narrow scope of a variable to be less confusing

Sure. I'll push it to the clowncopter, thanks.

Patch

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -1994,19 +1994,19 @@  static PyObject *find_deepest(indexObjec
 
 		for (i = 0; i < 2; i++) {
 			int p = parents[i];
-			long nsp, sp;
+			long sp;
 			int dp;
 
 			if (p == -1)
 				continue;
 
 			dp = depth[p];
-			nsp = sp = seen[p];
+			sp = seen[p];
 			if (dp <= dv) {
 				depth[p] = dv + 1;
 				if (sp != sv) {
 					interesting[sv] += 1;
-					nsp = seen[p] = sv;
+					seen[p] = sv;
 					if (sp) {
 						interesting[sp] -= 1;
 						if (interesting[sp] == 0)
@@ -2015,7 +2015,7 @@  static PyObject *find_deepest(indexObjec
 				}
 			}
 			else if (dv == dp - 1) {
-				nsp = sp | sv;
+				long nsp = sp | sv;
 				if (nsp == sp)
 					continue;
 				seen[p] = nsp;