Skip to content

Commit

Permalink
Optimize parsing of definition
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-klein committed Dec 2, 2023
1 parent c785597 commit 68c280a
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/sword_backend/strongs_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,31 +251,28 @@ void StrongsEntry::parseFromVersion2RawEntry(string rawEntry)

// Parse the phonetic transcription
string phoneticTranscriptionTag = "<pron rend=\"italic\">{";
string phoneticTranscriptionEndTag = "}</pron>";
string phoneticTranscriptionEndTag = "}";
this->phoneticTranscription = this->parseFromVersion2Element(phoneticTranscription, phoneticTranscriptionTag, phoneticTranscriptionEndTag);

// Parse the definition
string definition = allLines[1];
string definition = rawEntry;
definition = this->parseFromVersion2Element(rawEntry, "<def>", "</def>");
string references = definition;

std::size_t lineBreakPosition = definition.find("<lb");
string defEndTag = "</def>";
std::size_t defEndTagPosition = definition.find(defEndTag);

StringHelper::trim(definition);

string lineBreak = "<lb/>";
lineBreakPosition = definition.find(lineBreak);

if (lineBreakPosition != string::npos) {
// Line break existing
definition.erase(lineBreakPosition, string::npos);
} else {
// No line break existing

if (defEndTagPosition != string::npos) {
definition.erase(defEndTagPosition, string::npos);
}
}

StringHelper::trim(definition);

// Parse the references
string references = allLines[1];
string lineBreak = "<lb/>";
lineBreakPosition = references.find(lineBreak);

if (lineBreakPosition != string::npos) {
Expand Down

0 comments on commit 68c280a

Please sign in to comment.