Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use named list for regex substitution of namespace prefixes
I profiled se lint because it seemed to be surprisingly slow for a fairly small repository. This revealed that half of the execution time was spent in the _replace_shorthand_namespaces method. For the same repository, changing that method to use a named list (and therefore, only a single call to regex.sub) reduced the time spent in that method from ~15 seconds to ~5 seconds. This optimization is correct, and arguably easier to understand, because a single attribute can only have one prefix. Using a named list also avoids the need to manually escape the prefixes before including them in the regex pattern, which this code was incorrectly skipping. Finally, this change corrects a mistake in that method's documentation, as the : suffix is not retained in the output.
- Loading branch information