Re: [JGIT PATCH v2 17/24] Added the class TreeFilePattern.
- From
Shawn O. Pearce <spearce@spearce.org>
- Date
- May 13, 2008, 01:22 UTC
- Message-ID
- <20080513012253.GF29038@spearce.org>
- In-Reply-To
- <1210623222-24908-18-git-send-email-florianskarten@web.de>
Florian Koeberle <florianskarten@web.de> wrote:
Show 12 quoted lines
> +/**
> + * Represents a pattern like "documents/*.txt" which matches all *.txt files in
> + * the tree documents.
> + *
> + */
> +class TreeFilePattern implements FilePattern {
> +
> + private final List<String> path;
> +
> + private final int offset;
> +
> + private final GlobalFilePattern globalFilePattern;Hmm. This looks a lot like the ComplexFilePattern class to me; only it has the optimization of avoiding the regex match on the leading parts of the path.
Wouldn't it be simpler to define ComplexFilePattern taking a List<FilePattern> and have two implementations of FilePattern; one that uses FNMatch and one that uses strict String.equals()? Then this entire class becomes unnecessary as the pattern "documents/technical/*.txt" can be handled by two ExactMatch instances followd by an FNMatch instance.
The performance difference is probably not even measurable, but the code will be less complicated and less special-cased.
-- Shawn.