• Niels Thykier's avatar
    Rewrite some uses of keys() in if-statements · fb37242e
    Niels Thykier authored
    This rewrites the following statements:
    
        if a in b.keys():
    
    to
    
        if a in b:
    
    At the moment, both variants are cheap (i.e. O(1)) operations.
    However, the 2to3 will blindly rewrite the former into a more
    expensive variant, namely:
    
        if a in list(b.keys()):
    
    Sadly, this becomes O(|b|) as __contains__ on a list is a lot more
    expensive than it is on a directory/set-like structure.
    Signed-off-by: Niels Thykier's avatarNiels Thykier <niels@thykier.net>
    fb37242e