Skip to content

Commit 522537b

Browse files
committed
fix: remove unnecessary static/inline keywords
f
1 parent e1f0804 commit 522537b

File tree

10 files changed

+31
-30
lines changed

10 files changed

+31
-30
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ jobs:
139139
- name: Build Native Windows 32
140140
if: ${{ matrix.os == 'windows-2019' && matrix.node_arch == 'ia32' }}
141141
run:
142-
node ./node_modules/@aminya/cmake-ts/build/main.js named-configs windows-x86
142+
node ./node_modules/@aminya/cmake-ts/build/main.js named-configs
143+
windows-x86
143144

144145
- name: Use Node 20
145146
if: ${{ !matrix.docker }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"test.electron.renderer": "run-s build && electron-mocha --renderer",
108108
"lint-test.eslint": "eslint ./**/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/",
109109
"lint.eslint": "pnpm run lint-test.eslint --fix",
110-
"lint.clang-tidy": "git ls-files --exclude-standard | grep -E '\\.(cpp|hpp|c|cc|cxx|hxx|h|ixx)$' | xargs -n 1 -P $(nproc) clang-tidy --fix ",
110+
"lint.clang-tidy": "git ls-files --exclude-standard | grep -E '\\.(cpp|hpp|c|cc|cxx|hxx|h|ixx)$' | xargs -n 1 -P $(nproc) clang-tidy",
111111
"lint": "run-p format lint.eslint format",
112112
"lint-test": "run-s lint-test.eslint",
113113
"bench": "node --expose-gc test/bench",

src/module.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "util/error.h"
1111

1212
namespace zmq {
13-
static inline Napi::String Version(const Napi::Env& env) {
13+
Napi::String Version(const Napi::Env& env) {
1414
int32_t major = 0;
1515
int32_t minor = 0;
1616
int32_t patch = 0;
@@ -21,7 +21,7 @@ static inline Napi::String Version(const Napi::Env& env) {
2121
+ std::to_string(patch));
2222
}
2323

24-
static inline Napi::Object Capabilities(const Napi::Env& env) {
24+
Napi::Object Capabilities(const Napi::Env& env) {
2525
auto result = Napi::Object::New(env);
2626

2727
#ifdef ZMQ_HAS_CAPABILITIES
@@ -57,7 +57,7 @@ static inline Napi::Object Capabilities(const Napi::Env& env) {
5757
return result;
5858
}
5959

60-
static inline Napi::Value CurveKeyPair(const Napi::CallbackInfo& info) {
60+
Napi::Value CurveKeyPair(const Napi::CallbackInfo& info) {
6161
char public_key[41];
6262
char secret_key[41];
6363
if (zmq_curve_keypair(public_key, secret_key) < 0) {

src/observer.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "util/take.h"
1313

1414
namespace zmq {
15-
static constexpr const char* EventName(uint32_t val) {
15+
constexpr const char* EventName(uint32_t val) {
1616
switch (val) {
1717
case ZMQ_EVENT_CONNECTED:
1818
return "connect";
@@ -76,7 +76,7 @@ static constexpr const char* EventName(uint32_t val) {
7676
}
7777

7878
#ifdef ZMQ_EVENT_HANDSHAKE_FAILED_AUTH
79-
static constexpr const char* AuthError(uint32_t val) {
79+
constexpr const char* AuthError(uint32_t val) {
8080
switch (val) {
8181
case 300:
8282
return "Temporary error";
@@ -92,7 +92,7 @@ static constexpr const char* AuthError(uint32_t val) {
9292
#endif
9393

9494
#ifdef ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL
95-
static inline std::pair<const char*, const char*> ProtoError(uint32_t val) {
95+
std::pair<const char*, const char*> ProtoError(uint32_t val) {
9696
#define PROTO_ERROR_CASE(_prefix, _err) \
9797
case ZMQ_PROTOCOL_ERROR_##_prefix##_##_err: \
9898
return std::make_pair(#_prefix " protocol error", "ERR_" #_prefix "_" #_err);
@@ -157,20 +157,20 @@ Observer::Observer(const Napi::CallbackInfo& info)
157157
return;
158158
}
159159

160-
uv_os_sock_t fd = 0;
161-
size_t length = sizeof(fd);
160+
uv_os_sock_t file_descriptor = 0;
161+
size_t length = sizeof(file_descriptor);
162162

163163
if (zmq_connect(socket, address.c_str()) < 0) {
164164
ErrnoException(Env(), zmq_errno()).ThrowAsJavaScriptException();
165165
goto error;
166166
}
167167

168-
if (zmq_getsockopt(socket, ZMQ_FD, &fd, &length) < 0) {
168+
if (zmq_getsockopt(socket, ZMQ_FD, &file_descriptor, &length) < 0) {
169169
ErrnoException(Env(), zmq_errno()).ThrowAsJavaScriptException();
170170
goto error;
171171
}
172172

173-
if (poller.Initialize(Env(), fd) < 0) {
173+
if (poller.Initialize(Env(), file_descriptor) < 0) {
174174
ErrnoException(Env(), errno).ThrowAsJavaScriptException();
175175
goto error;
176176
}

src/socket.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Socket::Socket(const Napi::CallbackInfo& info)
101101
return;
102102
}
103103

104-
uv_os_sock_t fd = 0;
104+
uv_os_sock_t file_descriptor = 0;
105105
std::function<void()> const finalize = nullptr;
106106

107107
#ifdef ZMQ_THREAD_SAFE
@@ -153,14 +153,14 @@ Socket::Socket(const Napi::CallbackInfo& info)
153153
goto error;
154154
#endif
155155
} else {
156-
size_t length = sizeof(fd);
157-
if (zmq_getsockopt(socket, ZMQ_FD, &fd, &length) < 0) {
156+
size_t length = sizeof(file_descriptor);
157+
if (zmq_getsockopt(socket, ZMQ_FD, &file_descriptor, &length) < 0) {
158158
ErrnoException(Env(), zmq_errno()).ThrowAsJavaScriptException();
159159
goto error;
160160
}
161161
}
162162

163-
if (poller.Initialize(Env(), fd, finalize) < 0) {
163+
if (poller.Initialize(Env(), file_descriptor, finalize) < 0) {
164164
ErrnoException(Env(), errno).ThrowAsJavaScriptException();
165165
goto error;
166166
}

src/util/electron_helper.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ namespace zmq {
88
static bool hasRun = false;
99
static bool hasElectronMemoryCageCache = false;
1010

11-
static inline std::string first_component(std::string const& value) {
11+
inline std::string first_component(std::string const& value) {
1212
std::string::size_type const pos = value.find('.');
1313
return pos == std::string::npos ? value : value.substr(0, pos);
1414
}
1515

1616
/* Check if runtime is Electron. */
17-
static inline bool IsElectron(const Napi::Env& env) {
17+
inline bool IsElectron(const Napi::Env& env) {
1818
auto global = env.Global();
1919
auto isElectron = global.Get("process")
2020
.As<Napi::Object>()
@@ -24,7 +24,7 @@ static inline bool IsElectron(const Napi::Env& env) {
2424
return isElectron;
2525
}
2626

27-
static inline bool hasElectronMemoryCage(const Napi::Env& env) {
27+
inline bool hasElectronMemoryCage(const Napi::Env& env) {
2828
if (!hasRun) {
2929
if (IsElectron(env)) {
3030
auto electronVers = env.Global()

src/util/error.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ static constexpr const char* ErrnoMessage(int32_t errorno);
1212
static constexpr const char* ErrnoCode(int32_t errorno);
1313

1414
/* Generates a process warning message. */
15-
static inline void Warn(const Napi::Env& env, const std::string& msg) {
15+
inline void Warn(const Napi::Env& env, const std::string& msg) {
1616
auto global = env.Global();
17-
auto fn =
17+
auto emitWarning =
1818
global.Get("process").As<Napi::Object>().Get("emitWarning").As<Napi::Function>();
19-
fn.Call({Napi::String::New(env, msg)});
19+
emitWarning.Call({Napi::String::New(env, msg)});
2020
}
2121

22-
static inline Napi::Error StatusException(
22+
inline Napi::Error StatusException(
2323
const Napi::Env& env, const std::string& msg, uint32_t status) {
2424
Napi::HandleScope const scope(env);
2525
auto exception = Napi::Error::New(env, msg);
2626
exception.Set("status", Napi::Number::New(env, status));
2727
return exception;
2828
}
2929

30-
static inline Napi::Error CodedException(
30+
inline Napi::Error CodedException(
3131
const Napi::Env& env, const std::string& msg, const std::string& code) {
3232
Napi::HandleScope const scope(env);
3333
auto exception = Napi::Error::New(env, msg);
@@ -36,7 +36,7 @@ static inline Napi::Error CodedException(
3636
}
3737

3838
/* This mostly duplicates node::ErrnoException, but it is not public. */
39-
static inline Napi::Error ErrnoException(
39+
inline Napi::Error ErrnoException(
4040
const Napi::Env& env, int32_t error, const char* message = nullptr) {
4141
Napi::HandleScope const scope(env);
4242
auto exception =
@@ -46,7 +46,7 @@ static inline Napi::Error ErrnoException(
4646
return exception;
4747
}
4848

49-
static inline Napi::Error ErrnoException(
49+
inline Napi::Error ErrnoException(
5050
const Napi::Env& env, int32_t error, const std::string& address) {
5151
auto exception = ErrnoException(env, error, nullptr);
5252
exception.Set("address", Napi::String::New(env, address));

src/util/object.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
namespace zmq {
66
/* Seals an object to prevent setting incorrect options. */
7-
static inline void Seal(Napi::Object object) {
7+
inline void Seal(Napi::Object object) {
88
auto global = object.Env().Global();
99
auto seal = global.Get("Object").As<Napi::Object>().Get("seal").As<Napi::Function>();
1010
seal.Call({object});
1111
}
1212

1313
/* Assign all properties in the given options object. */
14-
static inline void Assign(Napi::Object object, Napi::Object options) {
14+
inline void Assign(Napi::Object object, Napi::Object options) {
1515
auto global = object.Env().Global();
1616
auto assign =
1717
global.Get("Object").As<Napi::Object>().Get("assign").As<Napi::Function>();

src/util/uvdelayed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class UvDelayed {
4646

4747
/* This is similar to JS setImmediate(). */
4848
template <typename C>
49-
static inline void UvScheduleDelayed(const Napi::Env& env, C callback) {
49+
inline void UvScheduleDelayed(const Napi::Env& env, C callback) {
5050
auto immediate = new UvDelayed<C>(env, std::move(callback));
5151
return immediate->Schedule();
5252
}

src/util/uvwork.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class UvWork {
4141
};
4242

4343
template <typename E, typename C>
44-
static inline int32_t UvQueue(const Napi::Env& env, E execute, C complete) {
44+
inline int32_t UvQueue(const Napi::Env& env, E execute, C complete) {
4545
auto* loop = UvLoop(env);
4646
auto work = new UvWork<E, C>(std::move(execute), std::move(complete));
4747
return work->Schedule(loop);

0 commit comments

Comments
 (0)