/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

Viewing changes to loggerhead/util.py

  • Committer: Robey Pointer
  • Date: 2006-12-15 01:14:05 UTC
  • Revision ID: robey@lag.net-20061215011405-cgtn85p3m41545vh
clean up the navbar, and add some profiling for the bad method.

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
    return '%s at %s' % (username, domains[0])
119
119
 
120
120
    
121
 
def triple_factors():
 
121
def triple_factors(min_value=1):
122
122
    factors = (1, 3)
123
123
    index = 0
124
124
    n = 1
125
125
    while True:
126
 
        if n >= 10:
 
126
        if n >= min_value:
127
127
            yield n * factors[index]
128
128
        index += 1
129
129
        if index >= len(factors):
131
131
            n *= 10
132
132
 
133
133
 
134
 
def scan_range(pos, max):
 
134
def scan_range(pos, max, pagesize=1):
135
135
    """
136
136
    given a position in a maximum range, return a list of negative and positive
137
137
    jump factors for an hgweb-style triple-factor geometric scan.
143
143
    invent it. :)
144
144
    """
145
145
    out = []
146
 
    for n in triple_factors():
 
146
    for n in triple_factors(pagesize + 1):
147
147
        if n > max:
148
148
            return out
149
149
        if pos + n < max: