Rev 2891: Tweak readv read-expansion logic. in http://people.ubuntu.com/~robertc/baz2.0/readv

Robert Collins robertc at robertcollins.net
Sat Oct 6 08:25:11 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/readv

------------------------------------------------------------
revno: 2891
revision-id: robertc at robertcollins.net-20071006072506-fypnagvqddbyh4q9
parent: pqm at pqm.ubuntu.com-20071005032619-b6c99y625rawducb
committer: Robert Collins <robertc at robertcollins.net>
branch nick: readv
timestamp: Sat 2007-10-06 17:25:06 +1000
message:
  Tweak readv read-expansion logic.
modified:
  bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py	2007-10-04 05:09:58 +0000
+++ b/bzrlib/transport/__init__.py	2007-10-06 07:25:06 +0000
@@ -673,15 +673,18 @@
                         yield None
                 return empty_yielder()
             # expand by page size at either end
-            expansion = self.recommended_page_size()
-            reduction = expansion / 2
+            maximum_expansion = self.recommended_page_size()
             new_offsets = []
             for offset, length in offsets:
+                expansion = maximum_expansion - length
+                if expansion < 0:
+                    # we're asking for more than the minimum read anyway.
+                    expansion = 0
+                reduction = expansion / 2
                 new_offset = offset - reduction
                 new_length = length + expansion
                 if new_offset < 0:
                     # don't ask for anything < 0
-                    new_length -= new_offset
                     new_offset = 0
                 if (upper_limit is not None and
                     new_offset + new_length > upper_limit):



More information about the bazaar-commits mailing list