Skip to content

Add a timestamp prescreen to update-from-model for better efficiency#17301

Merged
donho merged 2 commits intonotepad-plus-plus:masterfrom
pryrt:efficientFromModel
Dec 15, 2025
Merged

Add a timestamp prescreen to update-from-model for better efficiency#17301
donho merged 2 commits intonotepad-plus-plus:masterfrom
pryrt:efficientFromModel

Conversation

@pryrt
Copy link
Contributor

@pryrt pryrt commented Dec 14, 2025

I implemented @vlakoff's flow (c64b81e#commitcomment-172711882) based on @donho's statement (c64b81e#commitcomment-172721328)

resolves #17290

@chcg chcg added the enhancement Proposed enhancements of existing features label Dec 14, 2025
Copy link
Member

@donho donho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the modif timestamp should be read in "updateFromModelXml", but before calling it, as my comment shown:
c64b81e#commitcomment-172744627

@donho
Copy link
Member

donho commented Dec 14, 2025

Please follow the suggestion, and add the new commit into #17298.

@donho donho closed this Dec 14, 2025
@pryrt
Copy link
Contributor Author

pryrt commented Dec 14, 2025

the modif timestamp should be read in "updateFromModelXml", but before calling it, as my comment shown: c64b81e#commitcomment-172744627

I don't understand why. And I have two reasons that I thought were pretty good for putting the check where I did:

First, That would mean I would have to have separate (duplicate/repeated) code in both getUserStylesFromXml() and getLangKeywordsFromXmlTree(), which would be doing the same thing (instead of doing the check where I put it, near the beginning of updateFromModelXml() before anything time consuming has been executed, and exiting the function early if the update doesn't need to happen, just like I do for the modelDate check after the model has been read). Alternately, I could create a new function that was called from both of the getXYZ functions (to avoid repeated code), but you had indicated earlier that you didn't want to create a new function.

Second, I would also have to then pass in the modif timestamp into the updateFromModelXml() so that I could postpone updating the XML-structure's value until after I've stored the "old version" for comparing, whereas if I read the modified timestamp inside the function, the string doesn't need to pass around from one function to another, because then it would only ever need to be used in the common updateFromModelXml().

@donho
Copy link
Member

donho commented Dec 14, 2025

Hmm... You're right about it.

@donho donho reopened this Dec 14, 2025
@donho donho self-assigned this Dec 14, 2025
Copy link
Member

@donho donho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the suggestion:

std::wstring ws_modelModifTimestamp = std::to_wstring(modifyTime);

// if both strings exist, do the string comparison, and don't bother reading the model unless the user attribute appears out-of-date
if (!ws_user_modelModifTimestamp.empty() and !ws_modelModifTimestamp.empty())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Always use && instead of and
  • !ws_modelModifTimestamp.empty() will be always true - it can be removed.

@donho donho merged commit a73ddad into notepad-plus-plus:master Dec 15, 2025
12 checks passed
@pryrt pryrt deleted the efficientFromModel branch December 15, 2025 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Proposed enhancements of existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request] Make styler/theme/langs update-from-model more efficient

3 participants