X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Flzms-compress.c;h=a4d45300681f6871f14fcbec0886fb67cf9b3a6b;hp=0e9f0c3657d996bdaf9fe2dc669abc699e1e7961;hb=81c83fa2dbb44e788f234ddd5427c00e33c12d52;hpb=b7071062542143113ad654d89ee6b0603b23b524 diff --git a/src/lzms-compress.c b/src/lzms-compress.c index 0e9f0c36..a4d45300 100644 --- a/src/lzms-compress.c +++ b/src/lzms-compress.c @@ -116,7 +116,7 @@ struct lzms_range_encoder { * 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; @@ -669,17 +669,9 @@ lzms_do_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); } /*