Merge lp:~leonardr/lazr.batchnavigator/build-url-without-length into lp:lazr.batchnavigator
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Merged at revision: | 36 | ||||
| Proposed branch: | lp:~leonardr/lazr.batchnavigator/build-url-without-length | ||||
| Merge into: | lp:lazr.batchnavigator | ||||
| Diff against target: |
196 lines (+63/-16) 4 files modified
src/lazr/batchnavigator/NEWS.txt (+3/-1) src/lazr/batchnavigator/README.txt (+58/-13) src/lazr/batchnavigator/_batchnavigator.py (+1/-1) src/lazr/batchnavigator/z3batching/batch.py (+1/-1) |
||||
| To merge this branch: | bzr merge lp:~leonardr/lazr.batchnavigator/build-url-without-length | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Guilherme Salgado (community) | code | 2010-08-18 | Approve on 2010-08-19 |
|
Review via email:
|
|||
Description of the Change
A previous branch changed the Batch object to avoid calling len() unless it was absolutely necessary, since len() can be inefficient. This branch changes the BatchNavigator object to avoid calling len() unless absolutely necessary. (The places where it's absolutely necessary: getting the link to the final batch, and determining whether the header string is plural or not. The plural determination could probably be optimized further: whenever any batch data is present, we know whether there's one item in the batch or whether there's more. But this isn't what I'm trying to optimize just now.)
I use the same trick to test this as Benji used to test his changes to the Batch object. I define a simple subclass of the 'list' type that raises a RuntimeError when __len__ is called, and use it throughout the existing tests (except where noted).
- 37. By Leonard Richardson on 2010-08-19
-
Give up trying to optimize .heading after realizing that it doesn't matter, since .heading is always invoked immediately after an explicit determination of length.
- 38. By Leonard Richardson on 2010-08-19
-
Updated NEWS.

This looks very nice