On 07/23/2015 04:16 AM, Jean-Marc Lasgouttes wrote:
Le 23/07/2015 08:09, Jürgen Spitzmüller a écrit :
Am Donnerstag 23 Juli 2015, 00:43:35 schrieb Jean-Marc Lasgouttes:
Le 22/07/2015 17:42, Jürgen Spitzmüller a écrit :
Yes, this is with recent master. I can easily reproduce it with sec
2.5.1
of the User Guide, for instance (see attached screenshot).
OK, try again now. Let's see how it fares.
The problem is fixed. Looks quite good in general now, from what I
can see.
Except for #9691.
The big remaining problem though is that I rely on a
map<docstring,int> for caching word widths and this will probably fill
up with long editing sessions. In the original rowpainter2 code, there
were only words in the cache, and the number of words in a language is
much less than the number of string that can apear in a row...
I wonder how bad this will be. In practice, people do not actually use
that many different words when writing. Probably no more than a few
hundred, and a couple thousand, at most. Use of a hash, as you suggested
earlier, would probably be sufficient. I gather you just need to
implement qHash(docstring), as said in the FIXME, but that could be as
easy as:
uint qHash(const & docstring d) { return qHash(toqstr(d)); }
Alternatively, we could borrow the qHash code:
https://searchcode.com/codesearch/view/47469703/
From a quick look, it actually converts the QString to unicode before
operating on it:
uint qHash(const QString &key)
{
return hash(key.unicode(), key.size());
}
static uint hash(const uchar *p, int n)
{
uint h = 0;
while (n--) {
h = (h << 4) + *p++;
h ^= (h & 0xf0000000) >> 23;
h &= 0x0fffffff;
}
return h;
}
So we might just need some version of the latter.
Richard