PDA

View Full Version : Tipical newbie question



Dark_Tower
23rd March 2006, 18:37
Hi, I have a QStringList and I need to consult the string in a specified position various times (2 or 3 times). Do you think that's more eficient copying it in an auxiliar string variable or its fater consult the specified position in the list everytime because it doesn't need to do the copy?

high_flyer
23rd March 2006, 20:17
1. Please use descriptive subjects - a "Tipical newbie question" does not describe any problem
2. It will be faster to query the list directly.

Brandybuck
24th March 2006, 06:24
If you're only accessing the string two or three times, I wouldn't worry about it. But even if you do it a lot, QStringList is a QList, which is implemented internally as an array. There if very little overhead to calling mystringlist.at[n], for example. Sometimes I will use a reference to a QList item, for readability purposes, but it isn't necessary for efficiency.