Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 8209:a1a5a57efe90
replace util.sort with sorted built-in
This is marginally faster for small and moderately-sized lists
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 26 Apr 2009 16:50:44 -0500 |
parents | dd8d5be57d65 |
children | 46293a0c7e9f |
comparison
equal
deleted
inserted
replaced
8208:32a2a1e244f1 | 8209:a1a5a57efe90 |
---|---|
208 return pipefilter(s, cmd) | 208 return pipefilter(s, cmd) |
209 | 209 |
210 def binary(s): | 210 def binary(s): |
211 """return true if a string is binary data""" | 211 """return true if a string is binary data""" |
212 return bool(s and '\0' in s) | 212 return bool(s and '\0' in s) |
213 | |
214 def sort(l): | |
215 if not isinstance(l, list): | |
216 l = list(l) | |
217 l.sort() | |
218 return l | |
219 | 213 |
220 def increasingchunks(source, min=1024, max=65536): | 214 def increasingchunks(source, min=1024, max=65536): |
221 '''return no less than min bytes per chunk while data remains, | 215 '''return no less than min bytes per chunk while data remains, |
222 doubling min after each chunk until it reaches max''' | 216 doubling min after each chunk until it reaches max''' |
223 def log2(x): | 217 def log2(x): |