On Monday 27 October 2008 15:29:05 Jean-Marc Lasgouttes wrote: > José Matos <[EMAIL PROTECTED]> writes: > > So yes it should be possible to speed the conversion but there are > > reasons for the slow response. Up until this moment we have focused on > > making it correct, and just after we should make it fast. :-) > > It seems that this time has come :)
OK. I think that I have found the culprit. Attached follows a patch to lyx_1_6.py that cut the conversion time from 63 to 10 seconds in one of my recent slowest examples. FWIW the problem was that the unicode symbols were being read on each call of the functions that need them. In the case above that happened 918 times (!). I would appreciate the testing of this patch. The patch is straightforward and it should be correct. > JMarc -- José Abílio
Index: lyx_1_6.py =================================================================== --- lyx_1_6.py (revision 27154) +++ lyx_1_6.py (working copy) @@ -242,6 +242,8 @@ return retval +unicode_reps = read_unicodesymbols() + #Bug 5022.... #Might should do latex2ert first, then deal with stuff that DOESN'T #end up inside ERT. That routine could be modified so that it returned @@ -257,12 +259,11 @@ retval = [] # Convert LaTeX to Unicode - reps = read_unicodesymbols() # Commands of this sort need to be checked to make sure they are # followed by a non-alpha character, lest we replace too much. hardone = re.compile(r'^\\\\[a-zA-Z]+$') - for rep in reps: + for rep in unicode_reps: if hardone.match(rep[0]): pos = 0 while True: @@ -315,7 +316,6 @@ # clean up multiline stuff content = "" ert_end = 0 - reps = read_unicodesymbols() for curline in range(len(lines)): line = lines[curline] @@ -372,7 +372,7 @@ line = line.replace('$', '\\${}') # Do the LyX text --> LaTeX conversion - for rep in reps: + for rep in unicode_reps: line = line.replace(rep[1], rep[0] + "{}") line = line.replace(r'\backslash', r'\textbackslash{}') line = line.replace(r'\series bold', r'\bfseries{}').replace(r'\series default', r'\mdseries{}')