mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 950281 - micro-optimize NS_TableDrivenQI by ensuring the table has at least 1 non-null entry; r=bsmedberg
This commit is contained in:
parent
02c94cf332
commit
cef4749188
@ -8,7 +8,7 @@ nsresult NS_FASTCALL
|
||||
NS_TableDrivenQI(void* aThis, const QITableEntry* entries,
|
||||
REFNSIID aIID, void **aInstancePtr)
|
||||
{
|
||||
while (entries->iid) {
|
||||
do {
|
||||
if (aIID.Equals(*entries->iid)) {
|
||||
nsISupports* r =
|
||||
reinterpret_cast<nsISupports*>
|
||||
@ -19,7 +19,7 @@ NS_TableDrivenQI(void* aThis, const QITableEntry* entries,
|
||||
}
|
||||
|
||||
++entries;
|
||||
}
|
||||
} while (entries->iid);
|
||||
|
||||
*aInstancePtr = nullptr;
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
|
@ -609,8 +609,15 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
|
||||
reinterpret_cast<char*>((_class*) 0x1000)) \
|
||||
},
|
||||
|
||||
/*
|
||||
* XXX: we want to use mozilla::ArrayLength (or equivalent,
|
||||
* MOZ_ARRAY_LENGTH) in this condition, but some versions of GCC don't
|
||||
* see that the static_assert condition is actually constant in those
|
||||
* cases, even with constexpr support (?).
|
||||
*/
|
||||
#define NS_INTERFACE_TABLE_END_WITH_PTR(_ptr) \
|
||||
{ nullptr, 0 } }; \
|
||||
static_assert((sizeof(table)/sizeof(table[0])) > 1, "need at least 1 interface"); \
|
||||
rv = NS_TableDrivenQI(static_cast<void*>(_ptr), \
|
||||
table, aIID, aInstancePtr);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user