Bug 353121 - [PATCH] ignore duplicate SpellError objects
Summary: [PATCH] ignore duplicate SpellError objects
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: gtkhtml3
Version: rawhide
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Matthew Barnes
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-10-25 19:40 UTC by Dan Williams
Modified: 2007-11-30 22:12 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-11-08 18:58:21 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
ignore duplicates when adding spelling error objects to a line's spell_errors list (3.18 KB, patch)
2007-10-25 19:40 UTC, Dan Williams
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
GNOME Bugzilla 495073 0 None None None Never

Description Dan Williams 2007-10-25 19:40:13 UTC
Don't add the same SpellError object to a line's spell_errors list.  Works
around whatever bug causes gtkhtml3's memory usage to balloon in certain
situations where it adds millions of duplicate SpellError objects to a line's
spell_errors list.  Keep the list sorted when merging objects too.  The
spell_errors_list_add() code is more complicated because it doesn't call
g_list_append_sorted() (which would search back through the list which was
already just searched anyway) but instead tries to be clever about where to
insert the item if it's not found.

Comment 1 Dan Williams 2007-10-25 19:40:13 UTC
Created attachment 237881 [details]
ignore duplicates when adding spelling error objects to a line's spell_errors list

Comment 2 Dan Williams 2007-10-25 19:43:14 UTC
Using a 15375 character long line of multiple words (me pressing asdfgwer and
space at random times) I couldn't determine a performance difference between
patched and unpatched versions with a stopwatch.  Each text line keeps track of
it's own spell_list, so the speed impact of searching through the spell_errors
list is usually nothing since most lines will have < 10 spelling errors, even if
they are computery things like patches with lots of acronyms and non-english words.


Comment 3 Dan Williams 2007-10-25 19:45:13 UTC
Ray; can you take a quick look at the patch too for more assurance that it's
correct?  Does linked list manipulation and I want to be sure it looks OK to a
few people :)

Comment 4 Matthew Barnes 2007-10-25 20:58:45 UTC
Looks like it should work.  An alternate approach that avoids the linked list
manipulation might be to define a spell_errors_list_merge() function that
consumes two sorted GLists returns a new sorted GList, free of dupes.

Something roughly like (in Python):

    def spell_errors_list_merge(L1, L2):
            L3 = []
            while L1 and L2:
                if L1[0] < L2[0]:          # se_cmp() < 0
                    n = L1.pop(0)          # g_list_remove_link()
                else:
                    n = L2.pop(0)          # g_list_remove_link()
                if not L3 or n != L3[0]:   # se_cmp() != 0
                    L3.insert(0, n)        # g_list_prepend()
            L3.reverse()                   # g_list_reverse()
            L3.extend(L1)                  # g_list_concat()
            L3.extend(L2)                  # g_list_concat()
            return L3

Comment 5 Matthew Barnes 2007-11-08 18:58:21 UTC
Pushing this upstream with a revised patch.  See [1] for further updates.

[1] http://bugzilla.gnome.org/show_bug.cgi?id=495073


Note You need to log in before you can comment on or make changes to this bug.