Domanda

In my Qt app I receive large data array from the remote server (in JSON) then parse it and storing it in QVariantList. Every element has certain fields (4 int and 3 string attributes). The question is about performance. Should I use an array of struct instead of QVariantList? Or something else? Will it speed up the search by attribute in array and reduce memory usage or there is no difference?

È stato utile?

Soluzione

Yes, replacing QVariantList to struct most likely will speed up your app in this case. To check if an element has specific attribute, you need to extract a string from QVariantList and compare it with the search request. If there are many objects, it will take much time. If an attribute is already stored in QString, comparation will be much faster.

However, it's hard to say for certain what will be faster. Only profilter can tell you that.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top