Skip to content

Commit 194ba01

Browse files
authored
Merge branch 'master' into sm/java-vector-simd
2 parents 4895a35 + 37e6890 commit 194ba01

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

Rakefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ desc "Generate parser with ragel"
4949
task :ragel => [JAVA_PARSER_SRC]
5050

5151
if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
52+
path_separator = File::PATH_SEPARATOR
5253
ENV['JAVA_HOME'] ||= [
5354
'/usr/local/java/jdk',
5455
'/usr/lib/jvm/java-6-openjdk',
5556
'/Library/Java/Home',
5657
].find { |c| File.directory?(c) }
5758
if ENV['JAVA_HOME']
5859
warn " *** JAVA_HOME is set to #{ENV['JAVA_HOME'].inspect}"
59-
ENV['PATH'] = ENV['PATH'].split(/:/).unshift(java_path = "#{ENV['JAVA_HOME']}/bin") * ':'
60+
ENV['PATH'] = ENV['PATH'].split(path_separator).unshift(java_path = "#{ENV['JAVA_HOME']}/bin") * path_separator
6061
warn " *** java binaries are assumed to be in #{java_path.inspect}"
6162
else
6263
warn " *** JAVA_HOME was not set or could not be guessed!"
@@ -65,8 +66,8 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
6566

6667
JRUBY_JAR = File.join(CONFIG["libdir"], "jruby.jar")
6768
if File.exist?(JRUBY_JAR)
68-
classpath = (Dir['java/lib/*.jar'] << 'java/src' << JRUBY_JAR) * ':'
6969
JAVA_SOURCES.each do |src|
70+
classpath = (Dir['java/lib/*.jar'] << 'java/src' << JRUBY_JAR) * path_separator
7071
obj = src.sub(/\.java\Z/, '.class')
7172
file obj => src do
7273
sh 'javac', '-classpath', classpath, '-source', '1.8', '-target', '1.8', src

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)