Skip to content

Commit 7ddf349

Browse files
committed
Cleanup function delecarations
1 parent b11ce01 commit 7ddf349

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

ext/json/ext/json.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ typedef unsigned char _Bool;
5555
#endif
5656

5757
#ifndef NORETURN
58+
#if defined(__has_attribute) && __has_attribute(noreturn)
59+
#define NORETURN(x) __attribute__((noreturn)) x
60+
#else
5861
#define NORETURN(x) x
5962
#endif
63+
#endif
6064

6165
#ifndef NOINLINE
6266
#if defined(__has_attribute) && __has_attribute(noinline)

ext/json/ext/parser/parser.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,7 @@ static void emit_parse_warning(const char *message, JSON_ParserState *state)
400400

401401
#define PARSE_ERROR_FRAGMENT_LEN 32
402402

403-
#ifdef RBIMPL_ATTR_NORETURN
404-
RBIMPL_ATTR_NORETURN()
405-
#endif
406-
static void raise_parse_error(const char *format, JSON_ParserState *state)
403+
NORETURN(static) void raise_parse_error(const char *format, JSON_ParserState *state)
407404
{
408405
unsigned char buffer[PARSE_ERROR_FRAGMENT_LEN + 3];
409406
long line, column;
@@ -449,10 +446,7 @@ static void raise_parse_error(const char *format, JSON_ParserState *state)
449446
rb_exc_raise(exc);
450447
}
451448

452-
#ifdef RBIMPL_ATTR_NORETURN
453-
RBIMPL_ATTR_NORETURN()
454-
#endif
455-
static void raise_parse_error_at(const char *format, JSON_ParserState *state, const char *at)
449+
NORETURN(static) void raise_parse_error_at(const char *format, JSON_ParserState *state, const char *at)
456450
{
457451
state->cursor = at;
458452
raise_parse_error(format, state);
@@ -777,7 +771,7 @@ NOINLINE(static) VALUE json_string_unescape(JSON_ParserState *state, JSON_Parser
777771

778772
#define MAX_FAST_INTEGER_SIZE 18
779773

780-
static VALUE json_decode_large_integer(const char *start, long len)
774+
NOINLINE(static) VALUE json_decode_large_integer(const char *start, long len)
781775
{
782776
VALUE buffer_v;
783777
char *buffer = RB_ALLOCV_N(char, buffer_v, len + 1);
@@ -788,8 +782,7 @@ static VALUE json_decode_large_integer(const char *start, long len)
788782
return number;
789783
}
790784

791-
static inline VALUE
792-
json_decode_integer(uint64_t mantissa, int mantissa_digits, bool negative, const char *start, const char *end)
785+
static inline VALUE json_decode_integer(uint64_t mantissa, int mantissa_digits, bool negative, const char *start, const char *end)
793786
{
794787
if (RB_LIKELY(mantissa_digits < MAX_FAST_INTEGER_SIZE)) {
795788
if (negative) {
@@ -801,7 +794,7 @@ json_decode_integer(uint64_t mantissa, int mantissa_digits, bool negative, const
801794
return json_decode_large_integer(start, end - start);
802795
}
803796

804-
static VALUE json_decode_large_float(const char *start, long len)
797+
NOINLINE(static) VALUE json_decode_large_float(const char *start, long len)
805798
{
806799
if (RB_LIKELY(len < 64)) {
807800
char buffer[64];
@@ -868,7 +861,7 @@ static VALUE json_find_duplicated_key(size_t count, const VALUE *pairs)
868861
return Qfalse;
869862
}
870863

871-
static void emit_duplicate_key_warning(JSON_ParserState *state, VALUE duplicate_key)
864+
NOINLINE(static) void emit_duplicate_key_warning(JSON_ParserState *state, VALUE duplicate_key)
872865
{
873866
VALUE message = rb_sprintf(
874867
"detected duplicate key %"PRIsVALUE" in JSON object. This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`",
@@ -879,10 +872,7 @@ static void emit_duplicate_key_warning(JSON_ParserState *state, VALUE duplicate_
879872
RB_GC_GUARD(message);
880873
}
881874

882-
#ifdef RBIMPL_ATTR_NORETURN
883-
RBIMPL_ATTR_NORETURN()
884-
#endif
885-
static void raise_duplicate_key_error(JSON_ParserState *state, VALUE duplicate_key)
875+
NORETURN(static) void raise_duplicate_key_error(JSON_ParserState *state, VALUE duplicate_key)
886876
{
887877
VALUE message = rb_sprintf(
888878
"duplicate key %"PRIsVALUE,

0 commit comments

Comments
 (0)