Cache diff to speed up when the diff is processed multiple times
[email protected]
BUG=
TEST=
Review URL: http://codereview.chromium.org/9127026
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@117040 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/presubmit_support.py b/presubmit_support.py
index 52416d3..79a61f8 100755
--- a/presubmit_support.py
+++ b/presubmit_support.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -558,6 +558,7 @@
AffectedFile.__init__(self, *args, **kwargs)
self._server_path = None
self._is_text_file = None
+ self._diff = None
def ServerPath(self):
if self._server_path is None:
@@ -598,8 +599,10 @@
return self._is_text_file
def GenerateScmDiff(self):
- return scm.SVN.GenerateDiff(
- [self.LocalPath()], self._local_root, False, None)
+ if self._diff is None:
+ self._diff = scm.SVN.GenerateDiff(
+ [self.LocalPath()], self._local_root, False, None)
+ return self._diff
class GitAffectedFile(AffectedFile):
@@ -611,6 +614,7 @@
AffectedFile.__init__(self, *args, **kwargs)
self._server_path = None
self._is_text_file = None
+ self._diff = None
def ServerPath(self):
if self._server_path is None:
@@ -645,7 +649,10 @@
return self._is_text_file
def GenerateScmDiff(self):
- return scm.GIT.GenerateDiff(self._local_root, files=[self.LocalPath(),])
+ if self._diff is None:
+ self._diff = scm.GIT.GenerateDiff(
+ self._local_root, files=[self.LocalPath(),])
+ return self._diff
class Change(object):