[MERGE] get_record_stream().get_bytes_as('chunked')

Robert Collins robertc at robertcollins.net
Thu Dec 11 19:11:28 GMT 2008


Robert Collins has voted tweak.
Status is now: Conditionally approved
Comment:
 > For example, imagine updating the working tree using 
"iter_files_chunks"
 > rather than "iter_files_bytes". We could stream the bytes for each 
file
> out, rather than having to hold the entire content in memory.

So for this, the interface is already generic enough - the bytes 
iterator could output the chunks.

> This is actually fast enough, that I would consider re-implementing
> osutils.split_lines() in terms of chunks_to_lines. (Timing shows it to
> be about 2x faster.)

please!

+    def test_smoketest(self):
+        self.assertEqual(['foo\n', 'bar\n', 'baz\n'],
+                         osutils.chunks_to_lines(['foo\nbar', 
'\nbaz\n']))
+        self.assertEqual(['foo\n', 'bar\n', 'baz\n'],
+                         osutils.chunks_to_lines(['foo\n', 'bar\n', 
'baz\n']))

I think you need tests for:
  - no trailing \n
  - leading \n
  - double \n
  - no \n at all (whole thing)
  - no \n in a single chunk at all


For details, see: 
http://bundlebuggy.aaronbentley.com/project/bzr/request/%3C49415F9E.6060509%40arbash-meinel.com%3E
Project: Bazaar



More information about the bazaar mailing list