Skip to content

Commit

Permalink
Various small speed improvements (#106)
Browse files Browse the repository at this point in the history
* Use non synchronized collections
* Use empty arrays when transforming collections to arrays
* Avoid tokenizing each file name twice
* Save a bunch of file system accesses
* Save a few percent on parsing
  • Loading branch information
gnodet committed Nov 18, 2020
1 parent 3a72ec3 commit 797cab4
Show file tree
Hide file tree
Showing 11 changed files with 470 additions and 351 deletions.
14 changes: 12 additions & 2 deletions src/main/java/org/codehaus/plexus/util/AbstractScanner.java
Expand Up @@ -246,7 +246,7 @@ public void setIncludes( String[] includes )
list.add( normalizePattern( include ) );
}
}
this.includes = list.toArray( new String[list.size()] );
this.includes = list.toArray( new String[0] );
}
}

Expand Down Expand Up @@ -276,7 +276,7 @@ public void setExcludes( String[] excludes )
list.add( normalizePattern( exclude ) );
}
}
this.excludes = list.toArray( new String[list.size()] );
this.excludes = list.toArray( new String[0] );
}
}

Expand Down Expand Up @@ -331,6 +331,11 @@ protected boolean isIncluded( String name, String[] tokenizedName )
return includesPatterns.matches( name, tokenizedName, isCaseSensitive );
}

protected boolean isIncluded( String name, char[][] tokenizedName )
{
return includesPatterns.matches( name, tokenizedName, isCaseSensitive );
}

/**
* Tests whether or not a name matches the start of at least one include pattern.
*
Expand Down Expand Up @@ -360,6 +365,11 @@ protected boolean isExcluded( String name, String[] tokenizedName )
return excludesPatterns.matches( name, tokenizedName, isCaseSensitive );
}

protected boolean isExcluded( String name, char[][] tokenizedName )
{
return excludesPatterns.matches( name, tokenizedName, isCaseSensitive );
}

/**
* Adds default exclusions to the current exclusions set.
*/
Expand Down

0 comments on commit 797cab4

Please sign in to comment.