Skip to content

Commit f2d41b9

Browse files
committed
CxxIssuesReportSensor: introduce short-cut in getInputFileTryRealPath()
* if the given path cannot be found in module we searched after the "real" path * shortcut: no need to perform the second search i the "real" path is equal to the given one * this shortcut should save a bit of run-time for the file-systems, which are case-sensitive (e.g. for the mainstream linux)
1 parent 59e82f7 commit f2d41b9

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxIssuesReportSensor.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,20 @@ private InputFile getInputFileTryRealPath(SensorContext sensorContext, String pa
150150
}
151151
return null;
152152
}
153+
154+
// if the real path is equals to the given one - skip search; we already
155+
// tried such path
156+
//
157+
// IMPORTANT: don't use Path::equals(), since it's dependent on file-system
158+
// SonarQube plugin API works with string paths, so the equality of strings
159+
// is important
160+
final String realPathString = realPath.toString();
161+
if (absolutePath.toString().equals(realPathString)) {
162+
return null;
163+
}
164+
153165
return sensorContext.fileSystem()
154-
.inputFile(sensorContext.fileSystem().predicates().hasAbsolutePath(realPath.toString()));
166+
.inputFile(sensorContext.fileSystem().predicates().hasAbsolutePath(realPathString));
155167
}
156168

157169
public InputFile getInputFileIfInProject(SensorContext sensorContext, String path) {

0 commit comments

Comments
 (0)