Patchwork [4,of,5] lazymanifest: extract function for iterating to next line

login
register
mail settings
Submitter Martin von Zweigbergk
Date March 11, 2015, 11:14 p.m.
Message ID <d503a9f83866a27df8f8.1426115666@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/8009/
State Superseded
Commit 3d485727e45ef4ceb3edb8b123ad58f49ae8a9fd
Headers show

Comments

Martin von Zweigbergk - March 11, 2015, 11:14 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1426104926 25200
#      Wed Mar 11 13:15:26 2015 -0700
# Node ID d503a9f83866a27df8f88fbd8ea1297d8dfc3327
# Parent  91e8436e566b285254d11aec6dc6694ae50ff6e8
lazymanifest: extract function for iterating to next line

This will soon be reused by keys iterator.

Patch

diff -r 91e8436e566b -r d503a9f83866 mercurial/manifest.c
--- a/mercurial/manifest.c	Wed Mar 11 13:35:34 2015 -0700
+++ b/mercurial/manifest.c	Wed Mar 11 13:15:26 2015 -0700
@@ -222,13 +222,8 @@ 
 	PyObject_Del(self);
 }
 
-static PyObject *lmiter_iternext(PyObject *o)
+static line *lmiter_nextline(lmIter *self)
 {
-	size_t pl;
-	line *l;
-	Py_ssize_t consumed;
-	PyObject *path = NULL, *hash = NULL, *flags = NULL;
-	lmIter *self = (lmIter *)o;
 	do {
 		self->pos++;
 		if (self->pos >= self->m->numlines) {
@@ -236,7 +231,19 @@ 
 		}
 		/* skip over deleted manifest entries */
 	} while (self->m->lines[self->pos].deleted);
-	l = self->m->lines + self->pos;
+	return self->m->lines + self->pos;
+}
+
+static PyObject *lmiter_iternext(PyObject *o)
+{
+	size_t pl;
+	line *l;
+	Py_ssize_t consumed;
+	PyObject *path = NULL, *hash = NULL, *flags = NULL;
+	l = lmiter_nextline((lmIter *)o);
+	if (!l) {
+		return NULL;
+	}
 	pl = pathlen(l);
 	path = PyString_FromStringAndSize(l->start, pl);
 	hash = nodeof(l);