aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java
index da482fa50a..79df1511d1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014, Andrey Loskutov <loskutov@gmx.de>
+ * Copyright (C) 2014, 2017 Andrey Loskutov <loskutov@gmx.de>
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -123,12 +123,15 @@ public class Strings {
static int count(String s, char c, boolean ignoreFirstLast) {
int start = 0;
int count = 0;
- while (true) {
+ int length = s.length();
+ while (start < length) {
start = s.indexOf(c, start);
- if (start == -1)
+ if (start == -1) {
break;
- if (!ignoreFirstLast || (start != 0 && start != s.length()))
+ }
+ if (!ignoreFirstLast || (start != 0 && start != length - 1)) {
count++;
+ }
start++;
}
return count;