[gimp/gimp-2-10] Issue #3718 - Large colorrc file causes lag when painting with a new color
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] Issue #3718 - Large colorrc file causes lag when painting with a new color
- Date: Wed, 7 Aug 2019 16:21:13 +0000 (UTC)
commit 8d15563f4cd7a66fd3f5601ba576cee9897c86e6
Author: Ell <ell_se yahoo com>
Date: Wed Aug 7 18:32:19 2019 +0300
Issue #3718 - Large colorrc file causes lag when painting with a new color
In gimp_palette_mru_add(), if the added color doesn't match an
existing color, don't look for two duplicate existing colors (which
has quadratic complexity), since there shouldn't be any under
normal circumstances (as we're not adding duplicates to begin
with).
(cherry picked from commit e60829767e0f7e2a1a7b17df2e2ea5d285365716)
app/core/gimppalettemru.c | 53 ++++++++---------------------------------------
1 file changed, 9 insertions(+), 44 deletions(-)
---
diff --git a/app/core/gimppalettemru.c b/app/core/gimppalettemru.c
index d67cef8674..7ca33ff991 100644
--- a/app/core/gimppalettemru.c
+++ b/app/core/gimppalettemru.c
@@ -187,9 +187,8 @@ void
gimp_palette_mru_add (GimpPaletteMru *mru,
const GimpRGB *color)
{
- GimpPalette *palette;
- GimpPaletteEntry *found = NULL;
- GList *list;
+ GimpPalette *palette;
+ GList *list;
g_return_if_fail (GIMP_IS_PALETTE_MRU (mru));
g_return_if_fail (color != NULL);
@@ -205,50 +204,16 @@ gimp_palette_mru_add (GimpPaletteMru *mru,
if (gimp_rgba_distance (&entry->color, color) < RGBA_EPSILON)
{
- found = entry;
-
- goto doit;
- }
- }
-
- /* if not, are there two equal colors? */
- if (! found)
- {
- for (list = gimp_palette_get_colors (palette);
- list;
- list = g_list_next (list))
- {
- GimpPaletteEntry *entry = list->data;
- GList *list2;
+ gimp_palette_move_entry (palette, entry, 0);
- for (list2 = g_list_next (list); list2; list2 = g_list_next (list2))
- {
- GimpPaletteEntry *entry2 = list2->data;
+ /* Even though they are nearly the same color, let's make them
+ * exactly equal.
+ */
+ gimp_palette_set_entry_color (palette, 0, color);
- if (gimp_rgba_distance (&entry->color,
- &entry2->color) < RGBA_EPSILON)
- {
- found = entry2;
-
- goto doit;
- }
- }
+ return;
}
}
- doit:
-
- if (found)
- {
- gimp_palette_move_entry (palette, found, 0);
- /* Even though they are nearly the same color, let's make them exactly
- * equal. */
- gimp_palette_set_entry_color (palette,
- 0,
- color);
- }
- else
- {
- gimp_palette_add_entry (palette, 0, _("History Color"), color);
- }
+ gimp_palette_add_entry (palette, 0, _("History Color"), color);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]