KDAB / cxx-qt

Safe interop between Rust and Qt
https://kdab.github.io/cxx-qt/book/
1.02k stars 67 forks source link

Consider when to use an equality comparison in the setter files for QProperty #1000

Open BenFordTytherington opened 1 month ago

BenFordTytherington commented 1 month ago

In the rust setter file, the following check is used

if self.#ident == value {

which may be extra unnecessary overhead and could be optimised?

ahayzen-kdab commented 1 month ago

If there is no NOTIFY for this qproperty do we want/need to compare if the value is the same, as we do not need to determine if we notify or not

LeonMatthesKDAB commented 1 month ago

Also, the type may not even have an Eq implementation. Can we detect that somehow?

ahayzen-kdab commented 1 month ago

Right at the moment when you have an auto generated setter and notify, we assume your type implements Eq and we ensure that we don't trigger notify when data doesn't change. If your type didn't implement Eq at least now you could write a custom setter :-)