Skip to content

Commit

Permalink
remove unnecessary mutex guard
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Aug 21, 2024
1 parent e3fe79c commit d482047
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/workerd/api/node/zlib-util.c++
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ kj::Maybe<CompressionError> ZlibContext::setDictionary() {
}

bool ZlibContext::initializeZlib() {
if (initialized.lockExclusive()) {
if (initialized) {
return false;
}
switch (mode) {
Expand All @@ -134,7 +134,7 @@ bool ZlibContext::initializeZlib() {
}

setDictionary();
*initialized.lockExclusive() = true;
initialized = true;
return true;
}

Expand Down Expand Up @@ -284,7 +284,7 @@ kj::Maybe<CompressionError> ZlibContext::setParams(int _level, int _strategy) {
}

void ZlibContext::close() {
if (!initialized.lockExclusive()) {
if (!initialized) {
dictionary.clear();
mode = ZlibMode::NONE;
return;
Expand Down
3 changes: 1 addition & 2 deletions src/workerd/api/node/zlib-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "zlib.h"
#include <kj/array.h>
#include <kj/compat/brotli.h>
#include <kj/mutex.h>
#include <kj/vector.h>

#include <cstdlib>
Expand Down Expand Up @@ -142,7 +141,7 @@ class ZlibContext final {
return {kj::str(message), kj::str(ZlibStrerror(err)), err};
};

kj::MutexGuarded<bool> initialized{false};
bool initialized = false;
ZlibMode mode = ZlibMode::NONE;
int flush = Z_NO_FLUSH;
int windowBits = 0;
Expand Down

0 comments on commit d482047

Please sign in to comment.