Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master-1, master-0, and 0.9.4

Support reusing known sha during object creation.

This results in > 10% performance improvement during operations like rev-list.

Changeset ee89c0b39405

Parent d0c3d74178d2

committed by Jelmer Vernooij

authored by Jelmer Vernooij

Changes to 3 files · Browse files at ee89c0b39405 Showing diff from parent d0c3d74178d2 Diff from another changeset...

Change 1 of 1 Show Entire File NEWS Stacked
 
7
8
9
 
 
 
10
11
12
 
7
8
9
10
11
12
13
14
15
@@ -7,6 +7,9 @@
  * Add Repo.set_description(). (Víðir Valberg Guðmundsson)     * Add a basic `dulwich.porcelain` module. (Jelmer Vernooij) + + * Various performance improvements for object access. + (Jelmer Vernooij)     CHANGES  
 
113
114
115
116
 
117
118
119
 
113
114
115
 
116
117
118
119
@@ -113,7 +113,7 @@
  def __getitem__(self, sha):   """Obtain an object by SHA1."""   type_num, uncomp = self.get_raw(sha) - return ShaFile.from_raw_string(type_num, uncomp) + return ShaFile.from_raw_string(type_num, uncomp, sha=sha)     def __iter__(self):   """Iterate over the SHAs that are present in this store."""
 
291
292
293
294
 
295
296
297
298
299
300
 
 
 
301
302
303
304
 
 
 
 
305
306
307
 
403
404
405
406
 
407
408
409
410
 
411
412
413
 
414
415
416
417
 
418
419
420
421
 
422
423
424
 
425
426
427
 
291
292
293
 
294
295
296
297
 
 
 
298
299
300
301
302
303
 
304
305
306
307
308
309
310
 
406
407
408
 
409
410
411
412
413
414
415
416
 
417
418
419
420
 
421
422
423
424
425
426
427
428
 
429
430
431
432
@@ -291,17 +291,20 @@
  self._deserialize(self._chunked_text)   self._needs_parsing = False   - def set_raw_string(self, text): + def set_raw_string(self, text, sha=None):   """Set the contents of this object from a serialized string."""   if type(text) != str:   raise TypeError(text) - self.set_raw_chunks([text]) - - def set_raw_chunks(self, chunks): + self.set_raw_chunks([text], sha) + + def set_raw_chunks(self, chunks, sha=None):   """Set the contents of this object from a list of chunks."""   self._chunked_text = chunks   self._deserialize(chunks) - self._sha = None + if sha is None: + self._sha = None + else: + self._sha = FixedSha(sha)   self._needs_parsing = False   self._needs_serialization = False   @@ -403,25 +406,27 @@
  raise ObjectFormatException("invalid object header")     @staticmethod - def from_raw_string(type_num, string): + def from_raw_string(type_num, string, sha=None):   """Creates an object of the indicated type from the raw string given.     :param type_num: The numeric type of the object.   :param string: The raw uncompressed contents. + :param sha: Optional known sha for the object   """   obj = object_class(type_num)() - obj.set_raw_string(string) + obj.set_raw_string(string, sha)   return obj     @staticmethod - def from_raw_chunks(type_num, chunks): + def from_raw_chunks(type_num, chunks, sha=None):   """Creates an object of the indicated type from the raw chunks given.     :param type_num: The numeric type of the object.   :param chunks: An iterable of the raw uncompressed contents. + :param sha: Optional known sha for the object   """   obj = object_class(type_num)() - obj.set_raw_chunks(chunks) + obj.set_raw_chunks(chunks, sha)   return obj     @classmethod