Просмотр исходного кода

Do not rely on ArrayIndexOutOfBoundsException to detect end of input

In the Config#StringReader we relied on ArrayIndexOutOfBoundsException
to detect the end of the input. Creation of exception with (deep) stack
trace can significantly degrade performance in case when we read
thousands of config files, like in the case when Gerrit reads all
external ids from the NoteDb.

Use the buf.length to detect the end of the input.

Change-Id: I12266f25751373a870ce3fa623cf2a95d882d521
tags/v5.1.12.201910011832-r
Saša Živkov 4 лет назад
Родитель
Сommit
3d8649ddef
1 измененных файлов: 2 добавлений и 4 удалений
  1. 2
    4
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java

+ 2
- 4
org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java Просмотреть файл

@@ -1457,12 +1457,10 @@ public class Config {
}

int read() {
try {
return buf[pos++];
} catch (ArrayIndexOutOfBoundsException e) {
pos = buf.length;
if (pos >= buf.length) {
return -1;
}
return buf[pos++];
}

void reset() {

Загрузка…
Отмена
Сохранить