Skip to content

Commit a497c71

Browse files
committed
Improve consistency of code style
1 parent c5af1b6 commit a497c71

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

ext/json/ext/generator/generator.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,8 @@ static inline unsigned char search_ascii_only_escape(search_state *search, const
586586
return 0;
587587
}
588588

589-
static inline void full_escape_UTF8_char(search_state *search, unsigned char ch_len) {
589+
static inline void full_escape_UTF8_char(search_state *search, unsigned char ch_len)
590+
{
590591
const unsigned char ch = (unsigned char)*search->ptr;
591592
switch (ch_len) {
592593
case 1: {
@@ -616,7 +617,7 @@ static inline void full_escape_UTF8_char(search_state *search, unsigned char ch_
616617

617618
uint32_t wchar = 0;
618619

619-
switch(ch_len) {
620+
switch (ch_len) {
620621
case 2:
621622
wchar = ch & 0x1F;
622623
break;
@@ -776,7 +777,8 @@ static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self)
776777
* _state_ is a JSON::State object, that can also be used to configure the
777778
* produced JSON string output further.
778779
*/
779-
static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self) {
780+
static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self)
781+
{
780782
rb_check_arity(argc, 0, 1);
781783
VALUE Vstate = cState_from_state_s(cState, argc == 1 ? argv[0] : Qnil);
782784
return cState_partial_generate(Vstate, self, generate_json_array, Qfalse);
@@ -838,7 +840,8 @@ static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self)
838840
*
839841
* Extends _modul_ with the String::Extend module.
840842
*/
841-
static VALUE mString_included_s(VALUE self, VALUE modul) {
843+
static VALUE mString_included_s(VALUE self, VALUE modul)
844+
{
842845
VALUE result = rb_funcall(modul, i_extend, 1, mString_Extend);
843846
rb_call_super(1, &modul);
844847
return result;
@@ -1083,7 +1086,7 @@ json_object_i(VALUE key, VALUE val, VALUE _arg)
10831086
}
10841087

10851088
VALUE key_to_s;
1086-
switch(rb_type(key)) {
1089+
switch (rb_type(key)) {
10871090
case T_STRING:
10881091
if (RB_LIKELY(RBASIC_CLASS(key) == rb_cString)) {
10891092
key_to_s = key;
@@ -1167,7 +1170,7 @@ static void generate_json_array(FBuffer *buffer, struct generate_json_data *data
11671170

11681171
fbuffer_append_char(buffer, '[');
11691172
if (RB_UNLIKELY(data->state->array_nl)) fbuffer_append_str(buffer, data->state->array_nl);
1170-
for(i = 0; i < RARRAY_LEN(obj); i++) {
1173+
for (i = 0; i < RARRAY_LEN(obj); i++) {
11711174
if (i > 0) {
11721175
fbuffer_append_char(buffer, ',');
11731176
if (RB_UNLIKELY(data->state->array_nl)) fbuffer_append_str(buffer, data->state->array_nl);
@@ -1252,7 +1255,7 @@ static void generate_json_string(FBuffer *buffer, struct generate_json_data *dat
12521255
search.chunk_base = NULL;
12531256
#endif /* HAVE_SIMD */
12541257

1255-
switch(rb_enc_str_coderange(obj)) {
1258+
switch (rb_enc_str_coderange(obj)) {
12561259
case ENC_CODERANGE_7BIT:
12571260
case ENC_CODERANGE_VALID:
12581261
if (RB_UNLIKELY(data->state->ascii_only)) {
@@ -2116,7 +2119,7 @@ void Init_generator(void)
21162119
rb_require("json/ext/generator/state");
21172120

21182121

2119-
switch(find_simd_implementation()) {
2122+
switch (find_simd_implementation()) {
21202123
#ifdef HAVE_SIMD
21212124
#ifdef HAVE_SIMD_NEON
21222125
case SIMD_NEON:

ext/json/ext/parser/parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ static void
540540
json_eat_comments(JSON_ParserState *state)
541541
{
542542
if (state->cursor + 1 < state->end) {
543-
switch(state->cursor[1]) {
543+
switch (state->cursor[1]) {
544544
case '/': {
545545
state->cursor = memchr(state->cursor, '\n', state->end - state->cursor);
546546
if (!state->cursor) {

ext/json/ext/simd/simd.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ typedef enum {
1818
#define HAVE_BUILTIN_CTZLL 0
1919
#endif
2020

21-
static inline uint32_t trailing_zeros64(uint64_t input) {
21+
static inline uint32_t trailing_zeros64(uint64_t input)
22+
{
2223
#if HAVE_BUILTIN_CTZLL
2324
return __builtin_ctzll(input);
2425
#else
@@ -32,7 +33,8 @@ static inline uint32_t trailing_zeros64(uint64_t input) {
3233
#endif
3334
}
3435

35-
static inline int trailing_zeros(int input) {
36+
static inline int trailing_zeros(int input)
37+
{
3638
#if HAVE_BUILTIN_CTZLL
3739
return __builtin_ctz(input);
3840
#else
@@ -59,7 +61,8 @@ static inline int trailing_zeros(int input) {
5961
#include <arm_neon.h>
6062

6163
#define FIND_SIMD_IMPLEMENTATION_DEFINED 1
62-
static inline SIMD_Implementation find_simd_implementation(void) {
64+
static inline SIMD_Implementation find_simd_implementation(void)
65+
{
6366
return SIMD_NEON;
6467
}
6568

@@ -89,7 +92,7 @@ static inline FORCE_INLINE uint64_t compute_chunk_mask_neon(const char *ptr)
8992

9093
static inline FORCE_INLINE int string_scan_simd_neon(const char **ptr, const char *end, uint64_t *mask)
9194
{
92-
while(*ptr + sizeof(uint8x16_t) <= end) {
95+
while (*ptr + sizeof(uint8x16_t) <= end) {
9396
uint64_t chunk_mask = compute_chunk_mask_neon(*ptr);
9497
if (chunk_mask) {
9598
*mask = chunk_mask;
@@ -161,7 +164,8 @@ static inline TARGET_SSE2 FORCE_INLINE int string_scan_simd_sse2(const char **pt
161164
#include <cpuid.h>
162165
#endif /* HAVE_CPUID_H */
163166

164-
static inline SIMD_Implementation find_simd_implementation(void) {
167+
static inline SIMD_Implementation find_simd_implementation(void)
168+
{
165169
// TODO Revisit. I think the SSE version now only uses SSE2 instructions.
166170
if (__builtin_cpu_supports("sse2")) {
167171
return SIMD_SSE2;
@@ -176,7 +180,8 @@ static inline SIMD_Implementation find_simd_implementation(void) {
176180
#endif /* JSON_ENABLE_SIMD */
177181

178182
#ifndef FIND_SIMD_IMPLEMENTATION_DEFINED
179-
static inline SIMD_Implementation find_simd_implementation(void) {
183+
static inline SIMD_Implementation find_simd_implementation(void)
184+
{
180185
return SIMD_NONE;
181186
}
182187
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy