[PATCH] Fix bug 5880 - very slow in setting language on entire document

From: Johnny Lee (typo_pl_at_hotmail.com)
Date: Fri Jan 16 2004 - 14:37:07 EST

  • Next message: msevior_at_physics.unimelb.edu.au: "Re: [PATCH] Fix bug 5880 - very slow in setting language on entire document"

    Here's my proposed patch to fix bug 5880, attached as bug5880diff.txt.

    I'm not sure if I understood all the code but my patch seems to give the
    same results. The large reduction in execution time does make me wonder if
    my patch is wrong.

    The cause of the slowdown when changing language for a large amount of text
    is that a change notification is sent for each char format modification to a
    text run. When the View gets a char format change notification, it gets the
    character format for the entire selection. This is an O(n) operation. When
    you do this for all the text fragments in the doc, you've got an O(n^2)

    Proposed fix is to defer the notifications until after the character format
    change has occurred for the entire selection. After the change, the
    notification is sent out.

    This patch will affect any operation which changes the format for a text
    selection using PD_Document::changeSpanFmt. Other similar operations which
    don't go thru this codepath may require similar mods.

    More info can be found here:

    Resulting speedup:

    8500ms => 120ms on the test document from bug 5880.

    Happy New Year,

    Find high-speed ‘net deals — comparison-shop your local providers here.

    This archive was generated by hypermail 2.1.4 : Fri Jan 16 2004 - 14:37:29 EST