| OLD | NEW |
| 1 # Copyright 2016 The LUCI Authors. All rights reserved. | 1 # Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Implements an integer set compression algorithm based on delta | 5 """Implements an integer set compression algorithm based on delta |
| 6 encoded varints, which is then deflate'd. | 6 encoded varints, which is then deflate'd. |
| 7 | 7 |
| 8 The algorithm is intentionally simple. | 8 The algorithm is intentionally simple. |
| 9 | 9 |
| 10 This only works with sorted list of integers. The resulting compression level | 10 This only works with sorted list of integers. The resulting compression level |
| 11 can be very high for monotonically increasing sets. | 11 can be very high for monotonically increasing sets. |
| 12 """ | 12 """ |
| 13 | 13 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 val_byte = ord(d) | 62 val_byte = ord(d) |
| 63 value += (val_byte & 0x7F) * base | 63 value += (val_byte & 0x7F) * base |
| 64 if val_byte & 0x80: | 64 if val_byte & 0x80: |
| 65 base <<= 7 | 65 base <<= 7 |
| 66 else: | 66 else: |
| 67 out.append(value + last) | 67 out.append(value + last) |
| 68 last += value | 68 last += value |
| 69 value = 0 | 69 value = 0 |
| 70 base = 1 | 70 base = 1 |
| 71 return out | 71 return out |
| OLD | NEW |