Bug 353121

Summary: [PATCH] ignore duplicate SpellError objects
Product: [Fedora] Fedora Reporter: Dan Williams <dcbw>
Component: gtkhtml3Assignee: Matthew Barnes <mbarnes>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhideCC: mcrha, rstrode
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-11-08 18:58:21 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
ignore duplicates when adding spelling error objects to a line's spell_errors list none

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