1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-13 19:29:14 +01:00

[util] Add unlikely() around COM ref counting code

Improves code generation for the common case.
This commit is contained in:
Philip Rebohle 2019-06-02 23:34:53 +02:00
parent 818704d413
commit 19adccea8f

View File

@ -3,6 +3,8 @@
#include <atomic>
#include "com_include.h"
#include "../util_likely.h"
namespace dxvk {
@ -30,15 +32,15 @@ namespace dxvk {
virtual ~ComObject() { }
ULONG STDMETHODCALLTYPE AddRef() {
ULONG refCount = m_refCount++;
if (refCount == 0ul)
uint32_t refCount = m_refCount++;
if (unlikely(!refCount))
AddRefPrivate();
return refCount + 1;
}
ULONG STDMETHODCALLTYPE Release() {
ULONG refCount = --m_refCount;
if (refCount == 0ul)
uint32_t refCount = --m_refCount;
if (unlikely(!refCount))
ReleasePrivate();
return refCount;
}
@ -50,7 +52,8 @@ namespace dxvk {
void ReleasePrivate() {
if (--m_refPrivate == 0ul) {
uint32_t refPrivate = --m_refPrivate;
if (unlikely(!refPrivate)) {
m_refPrivate += 0x80000000;
delete this;
}