24/04/2013 21:41, pdv:
Why do you add 0x61 to the values?

That's just for easy reading when looking at what exactly gets written
to the map; In this way the codes are a, b, c ...

That makes sense.

I do not think there is a need to have a map per document. A shared map
stored in TextLetrics should be OK (like singleWidth currently).

I was worried that the map might grow out of proportion, e.g. when
leaving the application open for a long time and since there are more
words than characters this will be worse than for singleWidth.

I would start with the simple solution and then worry about a more complicated one. A shared map will take less total memory. If acces time is bad, then it may be worth implementing qHash(docstring) (by aping the QString version) and use a QHash<doctring, int>.

When typing it's unavoidable to generate all partials of a word; these
are removed again from the map so that only the final word remains;
However nothing is done to remedy the reverse: when deleting a word
character by character all partials will end-up in the map;

Did you do some measurement to ensure that there is a gain of doing that?

I don't think it makes so much difference in time. It was merely to
avoid filling the map with useless entries, especially if a single map
is used.

My policy in these kind of situation is to implement the simple solution and do optimization only when some measurement (profiling) proved that there is a problem to solve. Remember Knuth quote: "Premature optimization is the root of all evil (or at least most of it) in programming."

Do not hesitate to post patches as often as needed. While I do not have time to look at the hard parts of the patch right now, I think we move in the right direction.

JMarc

Reply via email to