citra-emu
/
citra
Archived
1
0
Fork 0

gl_resource_manager: Make use of noexcept on move assignment and move constructors

Several standard constructors generally check if objects can be moved in
a non-throwing manner (usually via std::move_if_noexcept) to preserve
its exception guarantees. This means that if these were used with
certain containers any reallocations internally would cause resource
churn, as copies would be necessary instead of moves.

This way, if they're every used in that manner, the right behavior is
always performed.
This commit is contained in:
Lioncash 2020-04-18 21:12:00 -04:00
parent 397bd1bb73
commit 12279b22cc
1 changed files with 8 additions and 8 deletions

View File

@ -41,13 +41,13 @@ class OGLTexture : private NonCopyable {
public: public:
OGLTexture() = default; OGLTexture() = default;
OGLTexture(OGLTexture&& o) : handle(std::exchange(o.handle, 0)) {} OGLTexture(OGLTexture&& o) noexcept : handle(std::exchange(o.handle, 0)) {}
~OGLTexture() { ~OGLTexture() {
Release(); Release();
} }
OGLTexture& operator=(OGLTexture&& o) { OGLTexture& operator=(OGLTexture&& o) noexcept {
Release(); Release();
handle = std::exchange(o.handle, 0); handle = std::exchange(o.handle, 0);
return *this; return *this;
@ -66,13 +66,13 @@ class OGLSampler : private NonCopyable {
public: public:
OGLSampler() = default; OGLSampler() = default;
OGLSampler(OGLSampler&& o) : handle(std::exchange(o.handle, 0)) {} OGLSampler(OGLSampler&& o) noexcept : handle(std::exchange(o.handle, 0)) {}
~OGLSampler() { ~OGLSampler() {
Release(); Release();
} }
OGLSampler& operator=(OGLSampler&& o) { OGLSampler& operator=(OGLSampler&& o) noexcept {
Release(); Release();
handle = std::exchange(o.handle, 0); handle = std::exchange(o.handle, 0);
return *this; return *this;
@ -91,13 +91,13 @@ class OGLShader : private NonCopyable {
public: public:
OGLShader() = default; OGLShader() = default;
OGLShader(OGLShader&& o) : handle(std::exchange(o.handle, 0)) {} OGLShader(OGLShader&& o) noexcept : handle(std::exchange(o.handle, 0)) {}
~OGLShader() { ~OGLShader() {
Release(); Release();
} }
OGLShader& operator=(OGLShader&& o) { OGLShader& operator=(OGLShader&& o) noexcept {
Release(); Release();
handle = std::exchange(o.handle, 0); handle = std::exchange(o.handle, 0);
return *this; return *this;
@ -114,13 +114,13 @@ class OGLProgram : private NonCopyable {
public: public:
OGLProgram() = default; OGLProgram() = default;
OGLProgram(OGLProgram&& o) : handle(std::exchange(o.handle, 0)) {} OGLProgram(OGLProgram&& o) noexcept : handle(std::exchange(o.handle, 0)) {}
~OGLProgram() { ~OGLProgram() {
Release(); Release();
} }
OGLProgram& operator=(OGLProgram&& o) { OGLProgram& operator=(OGLProgram&& o) noexcept {
Release(); Release();
handle = std::exchange(o.handle, 0); handle = std::exchange(o.handle, 0);
return *this; return *this;