[ https://issues.apache.org/jira/browse/LUCENENET-33?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
George Aroush reassigned LUCENENET-33: -------------------------------------- Assignee: George Aroush > Frequent exceptions at Single Parse(String s) > --------------------------------------------- > > Key: LUCENENET-33 > URL: https://issues.apache.org/jira/browse/LUCENENET-33 > Project: Lucene.Net > Issue Type: Improvement > Reporter: Vitaly Buka > Assigned To: George Aroush > Priority: Minor > > When Lucene running under Visual Studio's debugger it logs every fired > exception. This log slow down execution. "Single Parse(String s)" throw > exceptions very frequent so my program run slower in THOUSANDS of times. It > can be fixed with use of TryParse instead of Parse. > patch to fix it: > Index: Lucene.Net/Search/FieldCacheImpl.cs > =================================================================== > --- Lucene.Net/Search/FieldCacheImpl.cs (revision 500266) > +++ Lucene.Net/Search/FieldCacheImpl.cs (working copy) > @@ -264,14 +264,7 @@ > if (term == null || > term.Field() != field) > break; > float termval; > - try > - { > - termval = SupportClass.Single.Parse(term.Text()); > - } > - catch (Exception e) > - { > - termval = 0; > - } > + termval = > SupportClass.Single.Parse(term.Text()); > termDocs.Seek(termEnum); > while (termDocs.Next()) > { > @@ -514,4 +507,4 @@ > FLOAT_PARSER = new AnonymousClassFloatParser(); > } > } > -} > \ No newline at end of file > +} > Index: Lucene.Net/SupportClass.cs > =================================================================== > --- Lucene.Net/SupportClass.cs (revision 500266) > +++ Lucene.Net/SupportClass.cs (working copy) > @@ -589,17 +589,13 @@ > /// <returns></returns> > public static System.Single Parse(System.String s) > { > - try > - { > - if (s.EndsWith("f") || s.EndsWith("F")) > - return System.Single.Parse(s.Substring(0, s.Length - 1)); > - else > - return System.Single.Parse(s); > - } > - catch(System.FormatException fex) > - { > - throw fex; > - } > + System.Single res; > + > + if (s.EndsWith("f") || s.EndsWith("F")) > + System.Single.TryParse(s.Substring(0, s.Length - 1), out > res); > + else > + System.Single.TryParse(s, out res); > + return res; > } > } > > @@ -719,4 +715,4 @@ > } > } > } > -} > \ No newline at end of file > +} -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.