Some other function: The second one is short and faster than the first.

def computeLeadingWhitespaceWidth (s,tab_width):

    w = 0
    for ch in s:
        if ch == ' ':
            w += 1
        elif ch == '\t':
            w += (abs(tab_width) - (w % abs(tab_width)))
        else:
            break
    return w


def computeLeadingWhitespaceWidth2(s, tab_width):
    t = s.expandtabs(abs(tab_width))
    return len(t) - len(t.lstrip())


I don't know - are such micro-optimizations welcome or just a distraction?

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to