Skip to content

Commit

Permalink
Merge pull request #532 from techee/optimize_python
Browse files Browse the repository at this point in the history
python: optimize skipEverything()
  • Loading branch information
b4n committed Jun 25, 2015
2 parents 54eff29 + 6781ab3 commit d2052b5
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions tagmanager/ctags/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,20 +244,27 @@ static const char *skipEverything (const char *cp)
match = 1;

/* these checks find unicode, binary (Python 3) and raw strings */
if (!match && (
!strncasecmp(cp, "u'", 2) || !strncasecmp(cp, "u\"", 2) ||
!strncasecmp(cp, "r'", 2) || !strncasecmp(cp, "r\"", 2) ||
!strncasecmp(cp, "b'", 2) || !strncasecmp(cp, "b\"", 2)))
if (!match)
{
match = 1;
cp += 1;
}
if (!match && (
!strncasecmp(cp, "ur'", 3) || !strncasecmp(cp, "ur\"", 3) ||
!strncasecmp(cp, "br'", 3) || !strncasecmp(cp, "br\"", 3)))
{
match = 1;
cp += 2;
boolean r_first = (*cp == 'r' || *cp == 'R');

/* "r" | "R" | "u" | "U" | "b" | "B" */
if (r_first || *cp == 'u' || *cp == 'U' || *cp == 'b' || *cp == 'B')
{
unsigned int i = 1;

/* r_first -> "rb" | "rB" | "Rb" | "RB"
!r_first -> "ur" | "UR" | "Ur" | "uR" | "br" | "Br" | "bR" | "BR" */
if (( r_first && (cp[i] == 'b' || cp[i] == 'B')) ||
(!r_first && (cp[i] == 'r' || cp[i] == 'R')))
i++;

if (cp[i] == '\'' || cp[i] == '"')
{
match = 1;
cp += i;
}
}
}
if (match)
{
Expand Down

0 comments on commit d2052b5

Please sign in to comment.