[hibernate-dev] fix for https://hibernate.onjira.com/browse/HHH-766
Stepan Yakovenko
stiv.yakovenko at mail.ru
Sun Dec 16 03:52:43 EST 2012
HI!
StringHelper.firstIndexOfChar is extremely inefficient on long strings. It'd scan all string many times even if it starts with stop character. I propose to change it this way:
public static int firstIndexOfChar(String sqlString, String string, int startindex) {
Set stopchars = new HashSet();
for (int i = 0; i < string.length(); i++)
stopchars.add(string.charAt(i));
for (int i = startindex; i < sqlString.length(); i++) {
if (stopchars.contains(sqlString.charAt(i)))
return i;
}
return -1;
}
works fine in my project.
Stepan Yakovenko, stiv.yakovenko at mail.ru, +79039036253
More information about the hibernate-dev
mailing list