diff options
author | Andrey Loskutov <loskutov@gmx.de> | 2014-11-07 16:30:44 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2014-11-18 10:58:26 +0100 |
commit | 2c940fa18a457c37e9aa7a8065e8d650c83589e2 (patch) | |
tree | 80770201657b1db088d556bb97adf582f271e509 /org.eclipse.jgit.test | |
parent | a31db826d4247d1ae91a243526bcb65423abafce (diff) | |
download | jgit-2c940fa18a457c37e9aa7a8065e8d650c83589e2.tar.gz jgit-2c940fa18a457c37e9aa7a8065e8d650c83589e2.zip |
Don't use java.util.regex for two simple wildcard cases
To improve ignore parser performance we can avoid using java.util.regex
code on simple wildcard patterns with leading or trailing asterisk. As
those patterns represent a majority of ignore rules, the index diff
performance can be drastically increased on huge repository with lot of
ignore rules.
Bug: 450466
Change-Id: I80428441cc8d5de5468813f841d89322413eed8b
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
3 files changed, 26 insertions, 21 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/FastIgnoreRuleTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/FastIgnoreRuleTest.java index 656ba446d5..007bdcc5fc 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/FastIgnoreRuleTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/FastIgnoreRuleTest.java @@ -62,14 +62,14 @@ import org.junit.runners.Parameterized.Parameters; @RunWith(Parameterized.class) public class FastIgnoreRuleTest { - @Parameters(name = "JGit? {0}") + @Parameters(name = "OldRule? {0}") public static Iterable<Boolean[]> data() { return Arrays.asList(new Boolean[][] { { Boolean.FALSE }, { Boolean.TRUE } }); } @Parameter - public Boolean useJGitRule; + public Boolean useOldRule; @Test public void testSimpleCharClass() { @@ -388,11 +388,11 @@ public class FastIgnoreRuleTest { @SuppressWarnings("boxing") @Test public void testWildmatch() { - if (useJGitRule) + if (useOldRule) System.err .println("IgnoreRule can't understand wildmatch rules, skipping testWildmatch!"); - Boolean assume = useJGitRule; + Boolean assume = useOldRule; assertMatched("**/a/b", "a/b", assume); assertMatched("**/a/b", "c/a/b", assume); assertMatched("**/a/b", "c/d/a/b", assume); @@ -428,11 +428,11 @@ public class FastIgnoreRuleTest { @SuppressWarnings("boxing") @Test public void testWildmatchDoNotMatch() { - if (useJGitRule) + if (useOldRule) System.err .println("IgnoreRule can't understand wildmatch rules, skipping testWildmatchDoNotMatch!"); - Boolean assume = useJGitRule; + Boolean assume = useOldRule; assertNotMatched("**/a/b", "a/c/b", assume); assertNotMatched("!/**/*.zip", "c/a/b.zip", assume); assertNotMatched("!**/*.zip", "c/a/b.zip", assume); @@ -542,7 +542,7 @@ public class FastIgnoreRuleTest { */ private boolean match(String pattern, String target) { boolean isDirectory = target.endsWith("/"); - if (useJGitRule.booleanValue()) { + if (useOldRule.booleanValue()) { IgnoreRule r = new IgnoreRule(pattern); // If speed of this test is ever an issue, we can use a presetRule // field diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreMatcherParametrizedTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreMatcherParametrizedTest.java index 48649d6aee..cbfe6f2790 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreMatcherParametrizedTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreMatcherParametrizedTest.java @@ -60,14 +60,14 @@ import org.junit.runners.Parameterized.Parameters; @RunWith(Parameterized.class) public class IgnoreMatcherParametrizedTest { - @Parameters(name = "JGit? {0}") + @Parameters(name = "OldRule? {0}") public static Iterable<Boolean[]> data() { return Arrays.asList(new Boolean[][] { { Boolean.FALSE }, { Boolean.TRUE } }); } @Parameter - public Boolean useJGitRule; + public Boolean useOldRule; @Test public void testBasic() { @@ -355,7 +355,7 @@ public class IgnoreMatcherParametrizedTest { */ private boolean match(String pattern, String target) { boolean isDirectory = target.endsWith("/"); - if (useJGitRule.booleanValue()) { + if (useOldRule.booleanValue()) { IgnoreRule r = new IgnoreRule(pattern); // If speed of this test is ever an issue, we can use a presetRule // field diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreRuleSpecialCasesTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreRuleSpecialCasesTest.java index 109f28dabc..7afa69f441 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreRuleSpecialCasesTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreRuleSpecialCasesTest.java @@ -58,19 +58,19 @@ import org.junit.runners.Parameterized.Parameters; @SuppressWarnings({ "deprecation", "boxing" }) public class IgnoreRuleSpecialCasesTest { - @Parameters(name = "JGit? {0}") + @Parameters(name = "OldRule? {0}") public static Iterable<Boolean[]> data() { return Arrays.asList(new Boolean[][] { { Boolean.FALSE }, { Boolean.TRUE } }); } @Parameter - public Boolean useJGitRule; + public Boolean useOldRule; private void assertMatch(final String pattern, final String input, final boolean matchExpected, Boolean... assume) { boolean assumeDir = input.endsWith("/"); - if (useJGitRule.booleanValue()) { + if (useOldRule.booleanValue()) { final IgnoreRule matcher = new IgnoreRule(pattern); if (assume.length == 0 || !assume[0].booleanValue()) assertEquals(matchExpected, matcher.isMatch(input, assumeDir)); @@ -88,7 +88,7 @@ public class IgnoreRuleSpecialCasesTest { private void assertFileNameMatch(final String pattern, final String input, final boolean matchExpected) { boolean assumeDir = input.endsWith("/"); - if (useJGitRule.booleanValue()) { + if (useOldRule.booleanValue()) { final IgnoreRule matcher = new IgnoreRule(pattern); assertEquals(matchExpected, matcher.isMatch(input, assumeDir)); } else { @@ -99,10 +99,10 @@ public class IgnoreRuleSpecialCasesTest { @Test public void testVerySimplePatternCase0() throws Exception { - if (useJGitRule) + if (useOldRule) System.err .println("IgnoreRule can't understand blank lines, skipping"); - Boolean assume = useJGitRule; + Boolean assume = useOldRule; assertMatch("", "", false, assume); } @@ -800,9 +800,14 @@ public class IgnoreRuleSpecialCasesTest { @Test public void testSpecialGroupCase9() throws Exception { - if (useJGitRule) + assertMatch("][", "][", true); + } + + @Test + public void testSpecialGroupCase10() throws Exception { + if (useOldRule) System.err.println("IgnoreRule can't understand [[:], skipping"); - Boolean assume = useJGitRule; + Boolean assume = useOldRule; // Second bracket is threated literally, so both [ and : should match assertMatch("[[:]", ":", true, assume); assertMatch("[[:]", "[", true, assume); @@ -861,10 +866,10 @@ public class IgnoreRuleSpecialCasesTest { @Test public void testEscapedBackslash() throws Exception { - if (useJGitRule) + if (useOldRule) System.err .println("IgnoreRule can't understand escaped backslashes, skipping"); - Boolean assume = useJGitRule; + Boolean assume = useOldRule; // In Git CLI a\\b matches a\b file assertMatch("a\\\\b", "a\\b", true, assume); } @@ -899,4 +904,4 @@ public class IgnoreRuleSpecialCasesTest { assertFileNameMatch("a?b", "a\\b", true); } -}
\ No newline at end of file +} |