Fix: Reduce AnimData versioning overhead for node socket changes

Since the code only does anything if both substrings are found, implement
an early-out if either of them isn't found.

This seems like a micro-optimization at first, but since the current node
socket versioning requires looping over all AnimData in the file, this adds
up to e.g. 1.9sec saved when loading the Spring benchmark file.
This commit is contained in:
Lukas Stockner
2024-07-12 03:36:46 +02:00
parent 399498fdc0
commit ca39a60863

View File

@@ -789,14 +789,22 @@ static char *rna_path_rename_fix(ID *owner_id,
bool verify_paths)
{
char *prefixPtr = strstr(oldpath, prefix);
if (prefixPtr == nullptr) {
return oldpath;
}
char *oldNamePtr = strstr(oldpath, oldName);
if (oldNamePtr == nullptr) {
return oldpath;
}
int prefixLen = strlen(prefix);
int oldNameLen = strlen(oldName);
/* only start fixing the path if the prefix and oldName feature in the path,
* and prefix occurs immediately before oldName
*/
if ((prefixPtr && oldNamePtr) && (prefixPtr + prefixLen == oldNamePtr)) {
if (prefixPtr + prefixLen == oldNamePtr) {
/* if we haven't aren't able to resolve the path now, try again after fixing it */
if (!verify_paths || check_rna_path_is_valid(owner_id, oldpath) == 0) {
DynStr *ds = BLI_dynstr_new();