From: Thomas McGuire Date: Wed, 15 Aug 2012 07:33:18 +0000 (+0200) Subject: Document the vTable hack. X-Git-Tag: 1.0_branch~30 X-Git-Url: http://review.tizen.org/git/?p=profile%2Fivi%2Fqtdeclarative.git;a=commitdiff_plain;h=8f893d1d675b09d0a5f2add1df7a9970bb3cb227 Document the vTable hack. This was not immediately obvious, so better document this clever trick. Change-Id: I0d4a06396b9a709b29b46726d9a65d53600e3fa2 Reviewed-by: Chris Adams --- diff --git a/src/qml/qml/qqmlabstractbinding_p.h b/src/qml/qml/qqmlabstractbinding_p.h index 1ce0a23..a49b591 100644 --- a/src/qml/qml/qqmlabstractbinding_p.h +++ b/src/qml/qml/qqmlabstractbinding_p.h @@ -162,6 +162,14 @@ private: inline QQmlAbstractBinding *nextBinding() const; inline void setNextBinding(QQmlAbstractBinding *); + // Pointer to the next binding in the linked list of bindings. + // Being a pointer, the address is always aligned to at least 4 bytes, which means the last two + // bits of the pointer are free to be used for something else. They are used to store the binding + // type. The binding type serves as an index into the static vTables array, which is used instead + // of a compiler-generated vTable. Instead of virtual functions, pointers to static functions in + // the vTables array are used for dispatching. + // This saves a compiler-generated pointer to a compiler-generated vTable, and thus reduces + // the binding object size by sizeof(void*). uintptr_t m_nextBindingPtr; static VTable *vTables[];