summaryrefslogtreecommitdiffstats
path: root/src/xml
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-04-04 18:00:36 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-04-06 10:44:40 +0000
commit2fb7c94f63ce783c7f36149791fe72e053933ece (patch)
tree418bbff5f1d4681900298af1f4310a985d9b1564 /src/xml
parentad26d6a18d024d55a1325295cefafc991dc08a79 (diff)
QDom: optimize an atomic read
By the time setNodeValue() gets its hands on the removed object, the removeChild() function has already called removed->ref.deref(), which performs an acquire fence if the ref-count drops to zero. IOW: if removed->ref == 0 now, then an acquire fence has been executed. If ref != 0, then we're not reaching into removed, so we need no acquire. Therefore, a relaxed load suffices (as opposed to the loadAcquire() the implicit conversion operator performs). Found by disabling QAtomic<T> -> T implicit conversions. Change-Id: I367754fde0ad82db797161b5e94e2ebc08a90c0b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/xml')
-rw-r--r--src/xml/dom/qdom.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index 603704f916..a36d4389e4 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -3625,7 +3625,7 @@ void QDomAttrPrivate::setNodeValue(const QString& v)
t->ref.deref();
if (first) {
auto removed = removeChild(first);
- if (removed && !removed->ref)
+ if (removed && !removed->ref.loadRelaxed()) // removeChild() already deref()ed
delete removed;
}
appendChild(t);