mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
parent
e1d09ffe5d
commit
d0fdbef4ea
3 changed files with 23 additions and 15 deletions
|
@ -586,7 +586,8 @@ static inline unsigned char search_ascii_only_escape(search_state *search, const
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline void full_escape_UTF8_char(search_state *search, unsigned char ch_len) {
|
||||
static inline void full_escape_UTF8_char(search_state *search, unsigned char ch_len)
|
||||
{
|
||||
const unsigned char ch = (unsigned char)*search->ptr;
|
||||
switch (ch_len) {
|
||||
case 1: {
|
||||
|
@ -616,7 +617,7 @@ static inline void full_escape_UTF8_char(search_state *search, unsigned char ch_
|
|||
|
||||
uint32_t wchar = 0;
|
||||
|
||||
switch(ch_len) {
|
||||
switch (ch_len) {
|
||||
case 2:
|
||||
wchar = ch & 0x1F;
|
||||
break;
|
||||
|
@ -776,7 +777,8 @@ static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self)
|
|||
* _state_ is a JSON::State object, that can also be used to configure the
|
||||
* produced JSON string output further.
|
||||
*/
|
||||
static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self) {
|
||||
static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
rb_check_arity(argc, 0, 1);
|
||||
VALUE Vstate = cState_from_state_s(cState, argc == 1 ? argv[0] : Qnil);
|
||||
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)
|
|||
*
|
||||
* Extends _modul_ with the String::Extend module.
|
||||
*/
|
||||
static VALUE mString_included_s(VALUE self, VALUE modul) {
|
||||
static VALUE mString_included_s(VALUE self, VALUE modul)
|
||||
{
|
||||
VALUE result = rb_funcall(modul, i_extend, 1, mString_Extend);
|
||||
rb_call_super(1, &modul);
|
||||
return result;
|
||||
|
@ -1083,7 +1086,7 @@ json_object_i(VALUE key, VALUE val, VALUE _arg)
|
|||
}
|
||||
|
||||
VALUE key_to_s;
|
||||
switch(rb_type(key)) {
|
||||
switch (rb_type(key)) {
|
||||
case T_STRING:
|
||||
if (RB_LIKELY(RBASIC_CLASS(key) == rb_cString)) {
|
||||
key_to_s = key;
|
||||
|
@ -1167,7 +1170,7 @@ static void generate_json_array(FBuffer *buffer, struct generate_json_data *data
|
|||
|
||||
fbuffer_append_char(buffer, '[');
|
||||
if (RB_UNLIKELY(data->state->array_nl)) fbuffer_append_str(buffer, data->state->array_nl);
|
||||
for(i = 0; i < RARRAY_LEN(obj); i++) {
|
||||
for (i = 0; i < RARRAY_LEN(obj); i++) {
|
||||
if (i > 0) {
|
||||
fbuffer_append_char(buffer, ',');
|
||||
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
|
|||
search.chunk_base = NULL;
|
||||
#endif /* HAVE_SIMD */
|
||||
|
||||
switch(rb_enc_str_coderange(obj)) {
|
||||
switch (rb_enc_str_coderange(obj)) {
|
||||
case ENC_CODERANGE_7BIT:
|
||||
case ENC_CODERANGE_VALID:
|
||||
if (RB_UNLIKELY(data->state->ascii_only)) {
|
||||
|
@ -2116,7 +2119,7 @@ void Init_generator(void)
|
|||
rb_require("json/ext/generator/state");
|
||||
|
||||
|
||||
switch(find_simd_implementation()) {
|
||||
switch (find_simd_implementation()) {
|
||||
#ifdef HAVE_SIMD
|
||||
#ifdef HAVE_SIMD_NEON
|
||||
case SIMD_NEON:
|
||||
|
|
|
@ -540,7 +540,7 @@ static void
|
|||
json_eat_comments(JSON_ParserState *state)
|
||||
{
|
||||
if (state->cursor + 1 < state->end) {
|
||||
switch(state->cursor[1]) {
|
||||
switch (state->cursor[1]) {
|
||||
case '/': {
|
||||
state->cursor = memchr(state->cursor, '\n', state->end - state->cursor);
|
||||
if (!state->cursor) {
|
||||
|
|
|
@ -18,7 +18,8 @@ typedef enum {
|
|||
#define HAVE_BUILTIN_CTZLL 0
|
||||
#endif
|
||||
|
||||
static inline uint32_t trailing_zeros64(uint64_t input) {
|
||||
static inline uint32_t trailing_zeros64(uint64_t input)
|
||||
{
|
||||
#if HAVE_BUILTIN_CTZLL
|
||||
return __builtin_ctzll(input);
|
||||
#else
|
||||
|
@ -32,7 +33,8 @@ static inline uint32_t trailing_zeros64(uint64_t input) {
|
|||
#endif
|
||||
}
|
||||
|
||||
static inline int trailing_zeros(int input) {
|
||||
static inline int trailing_zeros(int input)
|
||||
{
|
||||
#if HAVE_BUILTIN_CTZLL
|
||||
return __builtin_ctz(input);
|
||||
#else
|
||||
|
@ -59,7 +61,8 @@ static inline int trailing_zeros(int input) {
|
|||
#include <arm_neon.h>
|
||||
|
||||
#define FIND_SIMD_IMPLEMENTATION_DEFINED 1
|
||||
static inline SIMD_Implementation find_simd_implementation(void) {
|
||||
static inline SIMD_Implementation find_simd_implementation(void)
|
||||
{
|
||||
return SIMD_NEON;
|
||||
}
|
||||
|
||||
|
@ -89,7 +92,7 @@ static inline FORCE_INLINE uint64_t compute_chunk_mask_neon(const char *ptr)
|
|||
|
||||
static inline FORCE_INLINE int string_scan_simd_neon(const char **ptr, const char *end, uint64_t *mask)
|
||||
{
|
||||
while(*ptr + sizeof(uint8x16_t) <= end) {
|
||||
while (*ptr + sizeof(uint8x16_t) <= end) {
|
||||
uint64_t chunk_mask = compute_chunk_mask_neon(*ptr);
|
||||
if (chunk_mask) {
|
||||
*mask = chunk_mask;
|
||||
|
@ -161,7 +164,8 @@ static inline TARGET_SSE2 FORCE_INLINE int string_scan_simd_sse2(const char **pt
|
|||
#include <cpuid.h>
|
||||
#endif /* HAVE_CPUID_H */
|
||||
|
||||
static inline SIMD_Implementation find_simd_implementation(void) {
|
||||
static inline SIMD_Implementation find_simd_implementation(void)
|
||||
{
|
||||
// TODO Revisit. I think the SSE version now only uses SSE2 instructions.
|
||||
if (__builtin_cpu_supports("sse2")) {
|
||||
return SIMD_SSE2;
|
||||
|
@ -176,7 +180,8 @@ static inline SIMD_Implementation find_simd_implementation(void) {
|
|||
#endif /* JSON_ENABLE_SIMD */
|
||||
|
||||
#ifndef FIND_SIMD_IMPLEMENTATION_DEFINED
|
||||
static inline SIMD_Implementation find_simd_implementation(void) {
|
||||
static inline SIMD_Implementation find_simd_implementation(void)
|
||||
{
|
||||
return SIMD_NONE;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue