[nostalgia/core] Make readObj move output object instead of copy
This commit is contained in:
parent
13ba8430c7
commit
9762a38a44
@ -25,22 +25,22 @@ ox::Result<AssetRef<T>> readObj(Context *ctx, const ox::FileAddress &file, bool
|
|||||||
}
|
}
|
||||||
oxReturnError(convert<T>(buff, &obj));
|
oxReturnError(convert<T>(buff, &obj));
|
||||||
}
|
}
|
||||||
return obj;
|
return std::move(obj);
|
||||||
};
|
};
|
||||||
oxRequire(path, file.getPath());
|
oxRequire(path, file.getPath());
|
||||||
if (forceLoad) {
|
if (forceLoad) {
|
||||||
oxRequire(buff, ctx->rom->read(file));
|
oxRequire(buff, ctx->rom->read(file));
|
||||||
oxRequire(obj, readConvert(buff));
|
oxRequire(obj, readConvert(buff));
|
||||||
oxRequire(cached, ctx->assetManager.template setAsset(path, obj));
|
oxRequire(cached, ctx->assetManager.setAsset(path, obj));
|
||||||
return cached;
|
return std::move(cached);
|
||||||
} else {
|
} else {
|
||||||
auto [cached, err] = ctx->assetManager.template getAsset<T>(path);
|
auto [cached, err] = ctx->assetManager.getAsset<T>(path);
|
||||||
if (err) {
|
if (err) {
|
||||||
oxRequire(buff, ctx->rom->read(file));
|
oxRequire(buff, ctx->rom->read(file));
|
||||||
oxRequire(obj, readConvert(buff));
|
oxRequire(obj, readConvert(buff));
|
||||||
oxReturnError(ctx->assetManager.template setAsset(path, obj).moveTo(&cached));
|
oxReturnError(ctx->assetManager.setAsset(path, obj).moveTo(&cached));
|
||||||
}
|
}
|
||||||
return cached;
|
return std::move(cached);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return OxError(1);
|
return OxError(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user