Bug 353121 - [PATCH] ignore duplicate SpellError objects
[PATCH] ignore duplicate SpellError objects
Product: Fedora
Classification: Fedora
Component: gtkhtml3 (Show other bugs)
All Linux
low Severity low
: ---
: ---
Assigned To: Matthew Barnes
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2007-10-25 15:40 EDT by Dan Williams
Modified: 2007-11-30 17:12 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-11-08 13:58:21 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

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 15:40 EDT, Dan Williams
no flags Details | Diff

External Trackers
Tracker ID Priority Status Summary Last Updated
GNOME Desktop 495073 None None None Never

  None (edit)
Description Dan Williams 2007-10-25 15:40:13 EDT
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 15:40:13 EDT
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 15:43:14 EDT
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 15:45:13 EDT
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 16:58:45 EDT
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()
                    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 13:58:21 EST
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.