Skip to content

Commit

Permalink
perf(GoogleDrive, WebDav): Don't loop through all lines when finding …
Browse files Browse the repository at this point in the history
…highest ID

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
  • Loading branch information
marcelklehr committed Jul 6, 2024
1 parent 96c8cb8 commit 20a2426
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/lib/adapters/GoogleDrive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,15 @@ export default class GoogleDriveAdapter extends CachingAdapter {

/* let's get the highestId */
const byNL = xmlDocText.split('\n')
byNL.forEach(line => {
for (const line of byNL) {
if (line.indexOf('<!--- highestId :') >= 0) {
const idxStart = line.indexOf(':') + 1
const idxEnd = line.lastIndexOf(':')

this.highestId = parseInt(line.substring(idxStart, idxEnd))
break
}
})
}

this.bookmarksCache = XbelSerializer.deserialize(xmlDocText)
if (this.lockingInterval) {
Expand Down
5 changes: 3 additions & 2 deletions src/lib/adapters/WebDav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,15 @@ export default class WebDavAdapter extends CachingAdapter {

/* let's get the highestId */
const byNL = xmlDocText.split('\n')
byNL.forEach(line => {
for (const line of byNL) {
if (line.indexOf('<!--- highestId :') >= 0) {
const idxStart = line.indexOf(':') + 1
const idxEnd = line.lastIndexOf(':')

this.highestId = parseInt(line.substring(idxStart, idxEnd))
break
}
})
}

switch (this.server.bookmark_file_type) {
case 'xbel':
Expand Down

0 comments on commit 20a2426

Please sign in to comment.