Skip to content

Commit

Permalink
Refactor: Reduce redundant calls to getActivatedEntryNumber in getEnt…
Browse files Browse the repository at this point in the history
…ryHeading

- Store the result of getActivatedEntryNumber in a local variable to avoid multiple method calls.
- Simplified the conditional logic by reusing the stored variable.
- Improves performance and code readability.
  • Loading branch information
RalfBarkow committed Oct 22, 2024
1 parent 6ff6235 commit 6e0a1ef
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/main/java/de/danielluedecke/zettelkasten/util/HtmlUbbUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,19 @@ private static String getEntryHeading(Daten dataObj, int entrynr, int sourcefram
StringBuilder heading = new StringBuilder();
heading.append(resourceMap.getString("zettelDesc")).append(" ");

if (entrynr != dataObj.getActivatedEntryNumber() && sourceframe != Constants.FRAME_SEARCH) {
// Store the result of getActivatedEntryNumber to avoid multiple calls
int activatedEntryNumber = dataObj.getActivatedEntryNumber();
Constants.zknlogger.info("Activated entry number: " + activatedEntryNumber);

if (entrynr != activatedEntryNumber && sourceframe != Constants.FRAME_SEARCH) {
heading.append("<a class=\"elink\" href=\"#activatedEntry\">")
.append(" ").append(dataObj.getActivatedEntryNumber()).append("&nbsp;</a>&raquo;&nbsp;")
.append("<a class=\"elink\" href=\"#cr_").append(entrynr).append("\">")
.append(entrynr).append("&nbsp;</a>(").append(wordCount).append(" ")
.append(resourceMap.getString("activatedZettelWordCount")).append(")");
.append(" ").append(activatedEntryNumber).append("&nbsp;</a>&raquo;&nbsp;")
.append("<a class=\"elink\" href=\"#cr_").append(entrynr).append("\">")
.append(entrynr).append("&nbsp;</a>(").append(wordCount).append(" ")
.append(resourceMap.getString("activatedZettelWordCount")).append(")");
} else {
heading.append(entrynr).append(" (").append(wordCount).append(" ")
.append(resourceMap.getString("activatedZettelWordCount")).append(")");
.append(resourceMap.getString("activatedZettelWordCount")).append(")");
}

return heading.toString();
Expand Down

0 comments on commit 6e0a1ef

Please sign in to comment.