[babl] babl: simplify the singleton logic in babl_format_with_space



commit 4586ca34b523b9cd2f14db68226d76e31af6f141
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Jul 11 20:35:37 2018 +0200

    babl: simplify the singleton logic in babl_format_with_space

 babl/babl-format.c | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)
---
diff --git a/babl/babl-format.c b/babl/babl-format.c
index bc5ef6b..3af5adc 100644
--- a/babl/babl-format.c
+++ b/babl/babl-format.c
@@ -148,7 +148,7 @@ format_new_from_format_with_space (const Babl *format, const Babl *space)
                     space,
                     format->format.component, format->format.sampling, (void*)format->format.type);
 
-
+  babl_db_insert (db, (void*)ret);
   return ret;
 }
 
@@ -713,8 +713,6 @@ BABL_CLASS_IMPLEMENT (format)
 const Babl *
 babl_format_with_space (const char *name, const Babl *space)
 {
-  const Babl *ret = NULL;
-
   if (!space) space = babl_space ("sRGB");
   if (space->class_type == BABL_FORMAT)
   {
@@ -731,21 +729,7 @@ babl_format_with_space (const char *name, const Babl *space)
   if (space == babl_space("sRGB"))
     return babl_format (name);
 
-  {
-    char *new_name = babl_malloc (strlen (name) +
-                                  strlen (babl_get_name ((Babl*)space)) + 2);
-    sprintf (new_name, "%s-%s", name, babl_get_name ((Babl*)space));
-
-    ret = babl_db_exist_by_name (db, new_name);
-
-    babl_free (new_name);
-    if (ret)
-      return ret;
-
-    ret = format_new_from_format_with_space (babl_format (name), space);
-    babl_db_insert (db, (void*)ret);
-  }
-  return ret;
+  return format_new_from_format_with_space (babl_format (name), space);
 }
 
 int


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]