Skip to content

Commit

Permalink
Merge pull request #2741 from cloudflare/felix/compact-short-blocks
Browse files Browse the repository at this point in the history
Enable clang-format AllowShortBlocksOnASingleLine
  • Loading branch information
fhanau authored Sep 19, 2024
2 parents 63650fe + 9ad67cc commit 501ef65
Show file tree
Hide file tree
Showing 18 changed files with 90 additions and 172 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ IncludeCategories:

AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AllowShortBlocksOnASingleLine: Empty

IndentWidth: 2
IndentCaseBlocks: false
Expand Down
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ f457f19039b82536b35659c1f9cb898a198e6cd1
# Use clang-format to sort includes.
faabf00af72bbce956221b40624f8a3d57f82b7c
b9e9fb144f44494017e77fbe959355e92f10ae69

# Add `AllowShortBlocksOnASingleLine: Empty` to clang-format
fa2c488219a5e96792e61f3d51838595e2907c8d
3 changes: 1 addition & 2 deletions src/workerd/api/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ class Blob: public jsg::Object {
KJ_CASE_ONEOF(b, jsg::Ref<Blob>) {
visitor.visit(b);
}
KJ_CASE_ONEOF(b, kj::Array<kj::byte>) {
}
KJ_CASE_ONEOF(b, kj::Array<kj::byte>) {}
}
}

Expand Down
12 changes: 4 additions & 8 deletions src/workerd/api/streams/internal.c++
Original file line number Diff line number Diff line change
Expand Up @@ -2483,8 +2483,7 @@ size_t WritableStreamInternalController::jsgGetMemorySelfSize() const {
}
void WritableStreamInternalController::jsgGetMemoryInfo(jsg::MemoryTracker& tracker) const {
KJ_SWITCH_ONEOF(state) {
KJ_CASE_ONEOF(closed, StreamStates::Closed) {
}
KJ_CASE_ONEOF(closed, StreamStates::Closed) {}
KJ_CASE_ONEOF(errored, StreamStates::Errored) {
tracker.trackField("error", errored);
}
Expand Down Expand Up @@ -2528,8 +2527,7 @@ size_t ReadableStreamInternalController::jsgGetMemorySelfSize() const {

void ReadableStreamInternalController::jsgGetMemoryInfo(jsg::MemoryTracker& tracker) const {
KJ_SWITCH_ONEOF(state) {
KJ_CASE_ONEOF(closed, StreamStates::Closed) {
}
KJ_CASE_ONEOF(closed, StreamStates::Closed) {}
KJ_CASE_ONEOF(error, StreamStates::Errored) {
tracker.trackField("error", error);
}
Expand All @@ -2542,10 +2540,8 @@ void ReadableStreamInternalController::jsgGetMemoryInfo(jsg::MemoryTracker& trac
}
}
KJ_SWITCH_ONEOF(readState) {
KJ_CASE_ONEOF(unlocked, Unlocked) {
}
KJ_CASE_ONEOF(locked, Locked) {
}
KJ_CASE_ONEOF(unlocked, Unlocked) {}
KJ_CASE_ONEOF(locked, Locked) {}
KJ_CASE_ONEOF(pipeLocked, PipeLocked) {
tracker.trackField("pipeLocked", pipeLocked);
}
Expand Down
24 changes: 8 additions & 16 deletions src/workerd/api/streams/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,8 @@ class ConsumerImpl final {

void cancel(jsg::Lock& js, jsg::Optional<v8::Local<v8::Value>> maybeReason) {
KJ_SWITCH_ONEOF(state) {
KJ_CASE_ONEOF(closed, Closed) {
}
KJ_CASE_ONEOF(errored, Errored) {
}
KJ_CASE_ONEOF(closed, Closed) {}
KJ_CASE_ONEOF(errored, Errored) {}
KJ_CASE_ONEOF(ready, Ready) {
for (auto& request: ready.readRequests) {
request.resolveAsDone(js);
Expand Down Expand Up @@ -505,10 +503,8 @@ class ConsumerImpl final {

void cancelPendingReads(jsg::Lock& js, jsg::JsValue reason) {
KJ_SWITCH_ONEOF(state) {
KJ_CASE_ONEOF(closed, Closed) {
}
KJ_CASE_ONEOF(errored, Errored) {
}
KJ_CASE_ONEOF(closed, Closed) {}
KJ_CASE_ONEOF(errored, Errored) {}
KJ_CASE_ONEOF(ready, Ready) {
for (auto& request: ready.readRequests) {
request.resolver.reject(js, reason);
Expand All @@ -520,8 +516,7 @@ class ConsumerImpl final {

void visitForGc(jsg::GcVisitor& visitor) {
KJ_SWITCH_ONEOF(state) {
KJ_CASE_ONEOF(closed, Closed) {
}
KJ_CASE_ONEOF(closed, Closed) {}
KJ_CASE_ONEOF(errored, Errored) {
// Technically we shouldn't really have to gc visit the stored error here but there
// should not be any harm in doing so.
Expand Down Expand Up @@ -1016,10 +1011,8 @@ size_t QueueImpl<Self>::jsgGetMemorySelfSize() const {
template <typename Self>
void QueueImpl<Self>::jsgGetMemoryInfo(jsg::MemoryTracker& tracker) const {
KJ_SWITCH_ONEOF(state) {
KJ_CASE_ONEOF(ready, Ready) {
}
KJ_CASE_ONEOF(closed, Closed) {
}
KJ_CASE_ONEOF(ready, Ready) {}
KJ_CASE_ONEOF(closed, Closed) {}
KJ_CASE_ONEOF(errored, Errored) {
tracker.trackField("error", errored);
}
Expand All @@ -1039,8 +1032,7 @@ size_t ConsumerImpl<Self>::jsgGetMemorySelfSize() const {
template <typename Self>
void ConsumerImpl<Self>::jsgGetMemoryInfo(jsg::MemoryTracker& tracker) const {
KJ_SWITCH_ONEOF(state) {
KJ_CASE_ONEOF(close, Closed) {
}
KJ_CASE_ONEOF(close, Closed) {}
KJ_CASE_ONEOF(error, Errored) {
tracker.trackField("error", error);
}
Expand Down
33 changes: 11 additions & 22 deletions src/workerd/api/streams/standard-test.c++
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ KJ_TEST("ReadableStream read all text (value readable)") {
c->close(js);
return js.resolvedPromise();
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableByteStreamController>) {
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableByteStreamController>) {}
}
KJ_UNREACHABLE;
}
Expand Down Expand Up @@ -120,8 +119,7 @@ KJ_TEST("ReadableStream read all text, rs ref held (value readable)") {
c->close(js);
return js.resolvedPromise();
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableByteStreamController>) {
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableByteStreamController>) {}
}
KJ_UNREACHABLE;
}
Expand Down Expand Up @@ -175,8 +173,7 @@ KJ_TEST("ReadableStream read all text (byte readable)") {
c->close(js);
return js.resolvedPromise();
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableStreamDefaultController>) {
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableStreamDefaultController>) {}
}
KJ_UNREACHABLE;
}
Expand Down Expand Up @@ -233,8 +230,7 @@ KJ_TEST("ReadableStream read all bytes (value readable)") {
c->close(js);
return js.resolvedPromise();
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableByteStreamController>) {
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableByteStreamController>) {}
}
KJ_UNREACHABLE;
}
Expand Down Expand Up @@ -292,8 +288,7 @@ KJ_TEST("ReadableStream read all bytes (byte readable)") {
c->close(js);
return js.resolvedPromise();
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableStreamDefaultController>) {
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableStreamDefaultController>) {}
}
KJ_UNREACHABLE;
}
Expand Down Expand Up @@ -356,8 +351,7 @@ KJ_TEST("ReadableStream read all bytes (value readable, more reads)") {

return js.resolvedPromise();
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableByteStreamController>) {
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableByteStreamController>) {}
}
KJ_UNREACHABLE;
}
Expand Down Expand Up @@ -421,8 +415,7 @@ KJ_TEST("ReadableStream read all bytes (byte readable, more reads)") {

return js.resolvedPromise();
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableStreamDefaultController>) {
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableStreamDefaultController>) {}
}
KJ_UNREACHABLE;
}
Expand Down Expand Up @@ -489,8 +482,7 @@ KJ_TEST("ReadableStream read all bytes (byte readable, large data)") {

return js.resolvedPromise();
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableStreamDefaultController>) {
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableStreamDefaultController>) {}
}
KJ_UNREACHABLE;
}
Expand Down Expand Up @@ -554,8 +546,7 @@ KJ_TEST("ReadableStream read all bytes (value readable, wrong type)") {
checked++;
return js.resolvedPromise();
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableByteStreamController>) {
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableByteStreamController>) {}
}
KJ_UNREACHABLE;
},
Expand Down Expand Up @@ -616,8 +607,7 @@ KJ_TEST("ReadableStream read all bytes (value readable, to many bytes)") {
checked++;
return js.resolvedPromise();
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableByteStreamController>) {
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableByteStreamController>) {}
}
KJ_UNREACHABLE;
}
Expand Down Expand Up @@ -673,8 +663,7 @@ KJ_TEST("ReadableStream read all bytes (byte readable, to many bytes)") {
checked++;
return js.resolvedPromise();
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableStreamDefaultController>) {
}
KJ_CASE_ONEOF(c, jsg::Ref<ReadableStreamDefaultController>) {}
}
KJ_UNREACHABLE;
}
Expand Down
Loading

0 comments on commit 501ef65

Please sign in to comment.