For my work I have to develop a small Java application that parses very large XML files (~300k lines) to select very specific data (using Pattern), so I'm trying to optimize it a little. I was wondering what was better between these 2 snippets:
if (boolean_condition && matcher.find(string)) {
...
}
OR
if (boolean_condition) {
if (matcher.find(string)) {
...
}
}
Other details:
- These if statements are executed on each iteration inside a loop (~20k iterations)
- The
boolean_conditionis abooleancalculated on each iteration using an external function - If the
booleanis set tofalse, I don't need to test the regular expression for matches
Thanks for your help.