# [PATCH] unneeded processing in forward_patches() ??

2 messages from 2005-12-02 to 2005-12-02. Participants: Chuck Lever.
Thread: https://gitlist.dev/t/2729

## Chuck Lever, 2005-12-02 00:11

Subject: [PATCH] unneeded processing in forward_patches() ??
Message-ID: <20051202001141.9140.23252.stgit@dexter.citi.umich.edu>
URL: https://gitlist.dev/e/20051202001141.9140.23252.stgit%40dexter.citi.umich.edu

```
i was wondering why "stg push" takes so long to decide not to use
fast-forward.

it turns out that when forward_patches() has not been able to fast-
forward any patches, it still does a git.switch() and rewrites the
unapplied file even though nothing has changed.  on a big working
directory, this 'no-op' can take a while.

following is a simple patch that addresses the problem.  does this appear
to be a reasonable optimization (in terms of correctness)?

        -- Chuck Lever
--
corporate:    <cel at netapp dot com>
personal:     <chucklever at bigfoot dot com>

```

## Chuck Lever, 2005-12-02 00:15

Subject: [PATCH] Fast-forwarding does a git.switch() even when it forwarded no patches
Message-ID: <20051202001513.9140.14792.stgit@dexter.citi.umich.edu>
URL: https://gitlist.dev/e/20051202001513.9140.14792.stgit%40dexter.citi.umich.edu
In-Reply-To: <20051202001141.9140.23252.stgit@dexter.citi.umich.edu>

```
The git.switch() in forward_patches() is not needed when no patches have
been fast forwarded.  This is a significant speed up.

Signed-off-by: Chuck Lever <cel@netapp.com>
---

 stgit/stack.py |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/stgit/stack.py b/stgit/stack.py
index 3fd6a46..3cc37c5 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -735,6 +735,9 @@ class Series:
             forwarded+=1
             unapplied.remove(name)
 
+        if forwarded == 0:
+            return 0
+
         git.switch(top)
 
         append_strings(self.__applied_file, names[0:forwarded])

```
