[hibernate-dev] fix for https://hibernate.onjira.com/browse/HHH-766

Strong Liu stliu at hibernate.org
Sun Dec 16 23:47:39 EST 2012


Stepan,

thanks for the patch, though there are some processes we'd like to use:

1. open a jira ( since HHH-766 is closed ) and link it to the original one (HHH-766)
2. give some numbers / tests to show your patch performs better than the old one
3. create a github pull request


p.s. from what i found, org.hibernate.internal.util.StringHelper#firstIndexOfChar is only used to search org.hibernate.hql.internal.classic.ParserHelper#HQL_SEPARATORS

so, maybe we should build a static set for it to avoid build the set every time.

On Dec 16, 2012, at 4:52 PM, Stepan Yakovenko <stiv.yakovenko at mail.ru> wrote:

> 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
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev

-------------------------
Best Regards,

Strong Liu <stliu at hibernate.org>
http://about.me/stliu/bio



More information about the hibernate-dev mailing list