>>>>> "Abdelrazak" == Abdelrazak Younes <[EMAIL PROTECTED]> writes:

Abdelrazak> Maybe my code is wrong but I'd really like to know why.
Abdelrazak> All I am doing is saving the pointer in the table. The
Abdelrazak> second time a font that has the same characteristics is
Abdelrazak> required, instead of creating it again I pass the one
Abdelrazak> created before. So the contruction of a new font is
Abdelrazak> skipped.

I do not think the code is wrong, but it is not better than the old
one (and as Andre' said, it evaluates the array indices twice).
The old code is

        /// Get font info (font + metrics) for the given LyX font.
        QLFontInfo & fontinfo(LyXFont const & f) {
                QLFontInfo * & fi =
                        
fontinfo_[f.family()][f.series()][f.realShape()][f.size()];
                if (!fi)
                        fi = new QLFontInfo(f);
                return *fi;
        }

The "QLFontInfo * & fi" construct means that fi's address is the table
entry. Therefore, "fi = new QLFontInfo(f);" does set the entry in the
array. 

Abdelrazak> If the pointer retrieved in the table is equal to zero
Abdelrazak> that means that this particular font was not used before
Abdelrazak> and we have to create it (via new) and save its pointer to
Abdelrazak> the table.

Abdelrazak> The older code was doing nothing as the table was filled
Abdelrazak> with zero and was never filled in anywhere!

Do you have evidence that it does not? It may be that I read
the code wrong.

Abdelrazak> I am doing just that. This patch is the direct analysis of
Abdelrazak> the profiling done by Bennett, please read that and the
Abdelrazak> analysis I made. Then, please explain me why I am wrong
Abdelrazak> when I think there is a problem with font caching under
Abdelrazak> MacOSX.

I think there is something wrong with the amount of time we compute
width of characters. 

- there are remnants of a charwidth caching in the qt3 frontend (for
  qt < 3.1, see USE_LYX_FONTCACHE). I remember that at the time I
  removed this, Bennett complained that it made LyX feel slower, and I
  disregarded his complaints... It may be time to revisit this.

- You asked about computing font width twice. Actually Andre did post
  a patch to avoid that, 
  http://marc.theaimsgroup.com/?l=lyx-devel&m=112825896416687&w=2
  but I think the results at the time were not very encouraging.

>> Otherwise, you could maybe find someone who has vtune...

Abdelrazak> I was trying to help MacOS port so I don't see how
Abdelrazak> profiling under wintel will help that as the two
Abdelrazak> implementions of Qt4.1 have very different performances.

The sluggishness of LyX/Qt 1.4 (wrt 1.3) is general, unfortunately.
Only the xforms frontend has reasonable performance.

JMarc

PS: looks like I am making you grumpy. It was not really intended.

Reply via email to