From 2fb7c94f63ce783c7f36149791fe72e053933ece Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 4 Apr 2022 18:00:36 +0200 Subject: 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 implicit conversions. Change-Id: I367754fde0ad82db797161b5e94e2ebc08a90c0b Reviewed-by: Thiago Macieira --- src/xml/dom/qdom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xml') 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); -- cgit v1.2.3