[meld] Inline misc.clamp(), and correctly use adjustment's lower as a min



commit 160ce50f69c1bc9c9c36ec900580be0deead6fa5
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Tue Mar 2 07:56:49 2010 +1000

    Inline misc.clamp(), and correctly use adjustment's lower as a min

 meld/filediff.py |    2 +-
 meld/misc.py     |    6 ------
 2 files changed, 1 insertions(+), 7 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 89c06f5..655ce3d 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1130,7 +1130,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
                 val, height = self.textview[i].get_line_yrange(it)
                 val -= (adj.page_size) * syncpoint
                 val += (other_line-int(other_line)) * height
-                val = misc.clamp(val, 0, adj.upper - adj.page_size)
+                val = min(max(val, adj.lower), adj.upper - adj.page_size)
                 adj.set_value( val )
 
                 # If we just changed the central bar, make it the master
diff --git a/meld/misc.py b/meld/misc.py
index 3a70e97..a434f1c 100644
--- a/meld/misc.py
+++ b/meld/misc.py
@@ -243,12 +243,6 @@ def write_pipe(command, text):
     proc.communicate(text)
     return proc.wait()
 
-def clamp(val, lower, upper):
-    """Clamp 'val' to the inclusive range [lower,upper].
-    """
-    assert lower <= upper
-    return min(max(val, lower), upper)
-
 def commonprefix(dirs):
     """Given a list of pathnames, returns the longest common leading component.
     """



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]