[babl] babl-cache: factor out construction of header line



commit fd2197646d46e4c4040e0f1c88c18ad63c3fe439
Author: Øyvind Kolås <pippin gimp org>
Date:   Tue Nov 29 22:45:56 2016 +0100

    babl-cache: factor out construction of header line

 babl/babl-cache.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/babl/babl-cache.c b/babl/babl-cache.c
index 1f0b6f5..818c126 100644
--- a/babl/babl-cache.c
+++ b/babl/babl-cache.c
@@ -135,6 +135,14 @@ static int compare_fish_pixels (const void *a, const void *b)
          ((*fb)->fish.processings - (*fa)->fish.processings);
 }
 
+static const char *cache_header (void)
+{
+  static char buf[2048];
+  sprintf (buf, "#%s BABL_PATH_LENGTH=%d BABL_TOLERANCE=%f",
+  BABL_GIT_VERSION, _babl_max_path_len (), _babl_legal_error ());
+  return buf;
+}
+
 void babl_store_db (void)
 {
   BablDb *db = babl_fish_db ();
@@ -142,8 +150,7 @@ void babl_store_db (void)
   FILE *dbfile = fopen (fish_cache_path (), "w");
   if (!dbfile)
     return;
-  fprintf (dbfile, "#%s BABL_PATH_LENGTH=%d BABL_TOLERANCE=%f\n",
-           BABL_GIT_VERSION, _babl_max_path_len (), _babl_legal_error ());
+  fprintf (dbfile, "%s\n", cache_header ());
 
   /* sort the list of fishes by usage, making next run more efficient -
    * and the data easier to approach as data for targeted optimization
@@ -254,10 +261,7 @@ void babl_init_db (void)
         case '#':
           /* if babl has changed in git .. drop whole cache */
           {
-            char buf[2048];
-            sprintf (buf, "#%s BABL_PATH_LENGTH=%d BABL_TOLERANCE=%f",
-               BABL_GIT_VERSION, _babl_max_path_len (), _babl_legal_error ());
-            if (strcmp ( token, buf))
+            if (strcmp ( token, cache_header ()))
             {
               free (contents);
               return;


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