]> wimlib.net Git - wimlib/blobdiff - src/lzms-compress.c
Merge branch 'lz_bt'
[wimlib] / src / lzms-compress.c
index 0e9f0c3657d996bdaf9fe2dc669abc699e1e7961..a4d45300681f6871f14fcbec0886fb67cf9b3a6b 100644 (file)
@@ -116,7 +116,7 @@ struct lzms_range_encoder {
         * lzms_range_encoder_raw.  */
        struct lzms_range_encoder_raw *rc;
 
         * lzms_range_encoder_raw.  */
        struct lzms_range_encoder_raw *rc;
 
-       /* Bits recently encoded by this range encoder.  This are used as in
+       /* Bits recently encoded by this range encoder.  This is used as an
         * index into @prob_entries.  */
        u32 state;
 
         * index into @prob_entries.  */
        u32 state;
 
@@ -669,17 +669,9 @@ lzms_do_init_rc_costs(void)
 static void
 lzms_init_rc_costs(void)
 {
 static void
 lzms_init_rc_costs(void)
 {
-       static bool done = false;
-       static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-
-       if (unlikely(!done)) {
-               pthread_mutex_lock(&mutex);
-               if (!done) {
-                       lzms_do_init_rc_costs();
-                       done = true;
-               }
-               pthread_mutex_unlock(&mutex);
-       }
+       static pthread_once_t once = PTHREAD_ONCE_INIT;
+
+       pthread_once(&once, lzms_do_init_rc_costs);
 }
 
 /*
 }
 
 /*