From 9e9b9619ab52e847dfbf311d8801223965d4b497 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 6 Feb 2025 13:07:06 +0100 Subject: [PATCH] Improve condition (#12469) --- .../importer/fileformat/BibtexParser.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java b/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java index adf2f95ef77..5d3cf9d0d33 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java @@ -354,21 +354,18 @@ private void parseJabRefComment(Map meta) { // We remove all line breaks in the metadata // These have been inserted to prevent too long lines when the file was saved, and are not part of the data. String comment = buffer.toString().replaceAll("[\\x0d\\x0a]", ""); - if (MetaData.META_FLAG.equals(comment.substring(0, Math.min(comment.length(), MetaData.META_FLAG.length())))) { - if (comment.startsWith(MetaData.META_FLAG)) { - String rest = comment.substring(MetaData.META_FLAG.length()); + if (comment.startsWith(MetaData.META_FLAG)) { + String rest = comment.substring(MetaData.META_FLAG.length()); - int pos = rest.indexOf(':'); + int pos = rest.indexOf(':'); - if (pos > 0) { - meta.put(rest.substring(0, pos), rest.substring(pos + 1)); + if (pos > 0) { + meta.put(rest.substring(0, pos), rest.substring(pos + 1)); - // meta comments are always re-written by JabRef and not stored in the file - dumpTextReadSoFarToString(); - } + // meta comments are always re-written by JabRef and not stored in the file + dumpTextReadSoFarToString(); } - } else if (MetaData.ENTRYTYPE_FLAG - .equals(comment.substring(0, Math.min(comment.length(), MetaData.ENTRYTYPE_FLAG.length())))) { + } else if (comment.startsWith(MetaData.ENTRYTYPE_FLAG)) { // A custom entry type can also be stored in a // "@comment" Optional typ = MetaDataParser.parseCustomEntryType(comment);