Thread (46 messages) flat view 46 messages, 5 authors, 2016-06-15

Re: [JGIT PATCH v2 17/24] Added the class TreeFilePattern.

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:44:36

Florian Koeberle [off-list ref] wrote:
+/**
+ * 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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help