From 6bca9962f31e82cb10cc5522c01422eb1aa40211 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Wed, 13 Aug 2025 13:52:40 -0700 Subject: [PATCH] Fix typos --- CHANGES.md | 16 +++--- benchmark/encoder.rb | 4 +- ext/json/ext/generator/generator.c | 4 +- ext/json/ext/parser/parser.c | 2 +- java/src/json/ext/ParserConfig.java | 84 ++++++++++++++--------------- lib/json.rb | 2 +- lib/json/common.rb | 2 +- test/json/ractor_test.rb | 2 +- 8 files changed, 58 insertions(+), 58 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 13b7e279f..eb6982ad5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -44,7 +44,7 @@ ### 2025-04-24 (2.11.1) * Add back `JSON.restore`, `JSON.unparse`, `JSON.fast_unparse` and `JSON.pretty_unparse`. - These were deprecated 16 years ago, but never emited warnings, only undocumented, so are + These were deprecated 16 years ago, but never emitted warnings, only undocumented, so are still used by a few gems. ### 2025-04-24 (2.11.0) @@ -71,7 +71,7 @@ ### 2025-03-12 (2.10.2) * Fix a potential crash in the C extension parser. -* Raise a ParserError on all incomplete unicode escape sequence. This was the behavior until `2.10.0` unadvertently changed it. +* Raise a ParserError on all incomplete unicode escape sequence. This was the behavior until `2.10.0` inadvertently changed it. * Ensure document snippets that are included in parser errors don't include truncated multibyte characters. * Ensure parser error snippets are valid UTF-8. * Fix `JSON::GeneratorError#detailed_message` on Ruby < 3.2 @@ -102,7 +102,7 @@ ### 2024-11-14 (2.8.2) -* `JSON.load_file` explictly read the file as UTF-8. +* `JSON.load_file` explicitly read the file as UTF-8. ### 2024-11-06 (2.8.1) @@ -110,7 +110,7 @@ ### 2024-11-06 (2.8.0) -* Emit a deprecation warning when `JSON.load` create custom types without the `create_additions` option being explictly enabled. +* Emit a deprecation warning when `JSON.load` create custom types without the `create_additions` option being explicitly enabled. * Prefer to use `JSON.unsafe_load(string)` or `JSON.load(string, create_additions: true)`. * Emit a deprecation warning when serializing valid UTF-8 strings encoded in `ASCII_8BIT` aka `BINARY`. * Bump required Ruby version to 2.7. @@ -118,7 +118,7 @@ pre-existing support for comments, make it suitable to parse `jsonc` documents. * Many performance improvements to `JSON.parse` and `JSON.load`, up to `1.7x` faster on real world documents. * Some minor performance improvements to `JSON.dump` and `JSON.generate`. -* `JSON.pretty_generate` no longer include newline inside empty object and arrays. +* `JSON.pretty_generate` no longer includes newlines inside empty object and arrays. ### 2024-11-04 (2.7.6) @@ -135,13 +135,13 @@ * Workaround a bug in 3.4.8 and older https://github.com/rubygems/rubygems/pull/6490. This bug would cause some gems with native extension to fail during compilation. * Workaround different versions of `json` and `json_pure` being loaded (not officially supported). -* Make `json_pure` Ractor compatible. +* Make `json_pure` Ractor compatible. ### 2024-10-24 (2.7.3) * Numerous performance optimizations in `JSON.generate` and `JSON.dump` (up to 2 times faster). -* Limit the size of ParserError exception messages, only include up to 32 bytes of the unparseable source. -* Fix json-pure's `Object#to_json` to accept non state arguments +* Limit the size of ParserError exception messages, only include up to 32 bytes of the unparsable source. +* Fix json-pure's `Object#to_json` to accept non-state arguments. * Fix multiline comment support in `json-pure`. * Fix `JSON.parse` to no longer mutate the argument encoding when passed an ASCII-8BIT string. * Fix `String#to_json` to raise on invalid encoding in `json-pure`. diff --git a/benchmark/encoder.rb b/benchmark/encoder.rb index f0a05dbd2..edda4e053 100644 --- a/benchmark/encoder.rb +++ b/benchmark/encoder.rb @@ -66,7 +66,7 @@ def benchmark_encoding(benchmark_name, ruby_obj, check_expected: true, except: [ # NB: Notes are based on ruby 3.3.4 (2024-07-09 revision be1089c8ec) +YJIT [arm64-darwin23] -# On the first two micro benchmarks, the limitting factor is the fixed cost of initializing the +# On the first two micro benchmarks, the limiting factor is the fixed cost of initializing the # generator state. Since `JSON.generate` now lazily allocate the `State` object we're now ~10-20% faster # than `Oj.dump`. benchmark_encoding "small mixed", [1, "string", { a: 1, b: 2 }, [3, 4, 5]] @@ -87,7 +87,7 @@ def benchmark_encoding(benchmark_name, ruby_obj, check_expected: true, except: [ # This benchmark spent the overwhelming majority of its time in `ruby_dtoa`. We rely on Ruby's implementation # which uses a relatively old version of dtoa.c from David M. Gay. # Oj in `compat` mode is ~10% slower than `json`, but in its default mode is noticeably faster here because -# it limits the precision of floats, breaking roundtriping. That's not something we should emulate. +# it limits the precision of floats, breaking roundtripping. That's not something we should emulate. # # Since a few years there are now much faster float to string implementations such as Ryu, Dragonbox, etc, # but all these are implemented in C++11 or newer, making it hard if not impossible to include them. diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c index 5248a9e26..9c6ed9304 100644 --- a/ext/json/ext/generator/generator.c +++ b/ext/json/ext/generator/generator.c @@ -137,8 +137,8 @@ static inline FORCE_INLINE void search_flush(search_state *search) { // Do not remove this conditional without profiling, specifically escape-heavy text. // escape_UTF8_char_basic will advance search->ptr and search->cursor (effectively a search_flush). - // For back-to-back characters that need to be escaped, specifcally for the SIMD code paths, this method - // will be called just before calling escape_UTF8_char_basic. There will be no characers to append for the + // For back-to-back characters that need to be escaped, specifically for the SIMD code paths, this method + // will be called just before calling escape_UTF8_char_basic. There will be no characters to append for the // consecutive characters that need to be escaped. While the fbuffer_append is a no-op if // nothing needs to be flushed, we can save a few memory references with this conditional. if (search->ptr > search->cursor) { diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index ab9d6c205..1e6ee753f 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -1265,7 +1265,7 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config) break; } - raise_parse_error("unreacheable: %s", state); + raise_parse_error("unreachable: %s", state); } static void json_ensure_eof(JSON_ParserState *state) diff --git a/java/src/json/ext/ParserConfig.java b/java/src/json/ext/ParserConfig.java index 2bd03babc..4a44f9be8 100644 --- a/java/src/json/ext/ParserConfig.java +++ b/java/src/json/ext/ParserConfig.java @@ -301,11 +301,11 @@ private RaiseException unexpectedToken(ThreadContext context, int absStart, int return parsingError(context, "unexpected token at '", absStart, absEnd); } - + // line 328 "ParserConfig.rl" - + // line 310 "ParserConfig.java" private static byte[] init__JSON_value_actions_0() { @@ -427,14 +427,14 @@ void parseValue(ThreadContext context, ParserResult res, int p, int pe) { int cs; IRubyObject result = null; - + // line 432 "ParserConfig.java" { cs = JSON_value_start; } // line 441 "ParserConfig.rl" - + // line 439 "ParserConfig.java" { int _klen; @@ -671,7 +671,7 @@ else if ( data[p] > _JSON_value_trans_keys[_mid+1] ) } } - + // line 676 "ParserConfig.java" private static byte[] init__JSON_integer_actions_0() { @@ -733,7 +733,7 @@ private static byte[] init__JSON_integer_index_offsets_0() private static final byte _JSON_integer_index_offsets[] = init__JSON_integer_index_offsets_0(); -private static byte[] init__JSON_integer_indicies_0() +private static byte[] init__JSON_integer_indices_0() { return new byte [] { 0, 2, 3, 1, 2, 3, 1, 1, 4, 1, 3, 4, @@ -741,7 +741,7 @@ private static byte[] init__JSON_integer_indicies_0() }; } -private static final byte _JSON_integer_indicies[] = init__JSON_integer_indicies_0(); +private static final byte _JSON_integer_indices[] = init__JSON_integer_indices_0(); private static byte[] init__JSON_integer_trans_targs_0() @@ -787,7 +787,7 @@ void parseInteger(ThreadContext context, ParserResult res, int p, int pe) { int parseIntegerInternal(int p, int pe) { int cs; - + // line 792 "ParserConfig.java" { cs = JSON_integer_start; @@ -795,7 +795,7 @@ int parseIntegerInternal(int p, int pe) { // line 480 "ParserConfig.rl" int memo = p; - + // line 800 "ParserConfig.java" { int _klen; @@ -866,7 +866,7 @@ else if ( data[p] > _JSON_integer_trans_keys[_mid+1] ) } } while (false); - _trans = _JSON_integer_indicies[_trans]; + _trans = _JSON_integer_indices[_trans]; cs = _JSON_integer_trans_targs[_trans]; if ( _JSON_integer_trans_actions[_trans] != 0 ) { @@ -922,7 +922,7 @@ RubyInteger bytesToInum(Ruby runtime, ByteList num) { return ConvertBytes.byteListToInum(runtime, num, 10, true); } - + // line 927 "ParserConfig.java" private static byte[] init__JSON_float_actions_0() { @@ -986,7 +986,7 @@ private static byte[] init__JSON_float_index_offsets_0() private static final byte _JSON_float_index_offsets[] = init__JSON_float_index_offsets_0(); -private static byte[] init__JSON_float_indicies_0() +private static byte[] init__JSON_float_indices_0() { return new byte [] { 0, 2, 3, 1, 2, 3, 1, 4, 5, 5, 1, 6, @@ -995,7 +995,7 @@ private static byte[] init__JSON_float_indicies_0() }; } -private static final byte _JSON_float_indicies[] = init__JSON_float_indicies_0(); +private static final byte _JSON_float_indices[] = init__JSON_float_indices_0(); private static byte[] init__JSON_float_trans_targs_0() @@ -1043,7 +1043,7 @@ void parseFloat(ThreadContext context, ParserResult res, int p, int pe) { int parseFloatInternal(int p, int pe) { int cs; - + // line 1048 "ParserConfig.java" { cs = JSON_float_start; @@ -1051,7 +1051,7 @@ int parseFloatInternal(int p, int pe) { // line 533 "ParserConfig.rl" int memo = p; - + // line 1056 "ParserConfig.java" { int _klen; @@ -1122,7 +1122,7 @@ else if ( data[p] > _JSON_float_trans_keys[_mid+1] ) } } while (false); - _trans = _JSON_float_indicies[_trans]; + _trans = _JSON_float_indices[_trans]; cs = _JSON_float_trans_targs[_trans]; if ( _JSON_float_trans_actions[_trans] != 0 ) { @@ -1168,7 +1168,7 @@ else if ( data[p] > _JSON_float_trans_keys[_mid+1] ) return p; } - + // line 1173 "ParserConfig.java" private static byte[] init__JSON_string_actions_0() { @@ -1232,7 +1232,7 @@ private static byte[] init__JSON_string_index_offsets_0() private static final byte _JSON_string_index_offsets[] = init__JSON_string_index_offsets_0(); -private static byte[] init__JSON_string_indicies_0() +private static byte[] init__JSON_string_indices_0() { return new byte [] { 0, 1, 2, 3, 1, 0, 4, 1, 0, 5, 5, 5, @@ -1241,7 +1241,7 @@ private static byte[] init__JSON_string_indicies_0() }; } -private static final byte _JSON_string_indicies[] = init__JSON_string_indicies_0(); +private static final byte _JSON_string_indices[] = init__JSON_string_indices_0(); private static byte[] init__JSON_string_trans_targs_0() @@ -1278,7 +1278,7 @@ void parseString(ThreadContext context, ParserResult res, int p, int pe) { int cs; IRubyObject result = null; - + // line 1283 "ParserConfig.java" { cs = JSON_string_start; @@ -1286,7 +1286,7 @@ void parseString(ThreadContext context, ParserResult res, int p, int pe) { // line 581 "ParserConfig.rl" int memo = p; - + // line 1291 "ParserConfig.java" { int _klen; @@ -1357,7 +1357,7 @@ else if ( data[p] > _JSON_string_trans_keys[_mid+1] ) } } while (false); - _trans = _JSON_string_indicies[_trans]; + _trans = _JSON_string_indices[_trans]; cs = _JSON_string_trans_targs[_trans]; if ( _JSON_string_trans_actions[_trans] != 0 ) { @@ -1429,7 +1429,7 @@ else if ( data[p] > _JSON_string_trans_keys[_mid+1] ) } } - + // line 1434 "ParserConfig.java" private static byte[] init__JSON_array_actions_0() { @@ -1549,7 +1549,7 @@ private static short[] init__JSON_array_index_offsets_0() private static final short _JSON_array_index_offsets[] = init__JSON_array_index_offsets_0(); -private static byte[] init__JSON_array_indicies_0() +private static byte[] init__JSON_array_indices_0() { return new byte [] { 0, 1, 0, 0, 2, 2, 3, 2, 2, 2, 4, 2, @@ -1565,7 +1565,7 @@ private static byte[] init__JSON_array_indicies_0() }; } -private static final byte _JSON_array_indicies[] = init__JSON_array_indicies_0(); +private static final byte _JSON_array_indices[] = init__JSON_array_indices_0(); private static byte[] init__JSON_array_trans_targs_0() @@ -1610,14 +1610,14 @@ void parseArray(ThreadContext context, ParserResult res, int p, int pe) { IRubyObject result = RubyArray.newArray(context.runtime); - + // line 1615 "ParserConfig.java" { cs = JSON_array_start; } // line 650 "ParserConfig.rl" - + // line 1622 "ParserConfig.java" { int _klen; @@ -1660,7 +1660,7 @@ else if ( _widec > _JSON_array_cond_keys[_mid+1] ) switch ( _JSON_array_cond_spaces[_JSON_array_cond_offsets[cs] + ((_mid - _keys)>>1)] ) { case 0: { _widec = 65536 + (data[p] - 0); - if ( + if ( // line 608 "ParserConfig.rl" config.allowTrailingComma ) _widec += 65536; break; @@ -1720,7 +1720,7 @@ else if ( _widec > _JSON_array_trans_keys[_mid+1] ) } } while (false); - _trans = _JSON_array_indicies[_trans]; + _trans = _JSON_array_indices[_trans]; cs = _JSON_array_trans_targs[_trans]; if ( _JSON_array_trans_actions[_trans] != 0 ) { @@ -1779,7 +1779,7 @@ else if ( _widec > _JSON_array_trans_keys[_mid+1] ) } } - + // line 1784 "ParserConfig.java" private static byte[] init__JSON_object_actions_0() { @@ -1906,7 +1906,7 @@ private static short[] init__JSON_object_index_offsets_0() private static final short _JSON_object_index_offsets[] = init__JSON_object_index_offsets_0(); -private static byte[] init__JSON_object_indicies_0() +private static byte[] init__JSON_object_indices_0() { return new byte [] { 0, 1, 0, 0, 2, 3, 4, 0, 1, 5, 5, 6, @@ -1923,7 +1923,7 @@ private static byte[] init__JSON_object_indicies_0() }; } -private static final byte _JSON_object_indicies[] = init__JSON_object_indicies_0(); +private static final byte _JSON_object_indices[] = init__JSON_object_indices_0(); private static byte[] init__JSON_object_trans_targs_0() @@ -1973,14 +1973,14 @@ void parseObject(ThreadContext context, ParserResult res, int p, int pe) { // allocator test at OptionsReader#getClass IRubyObject result = RubyHash.newHash(context.runtime); - + // line 1978 "ParserConfig.java" { cs = JSON_object_start; } // line 737 "ParserConfig.rl" - + // line 1985 "ParserConfig.java" { int _klen; @@ -2023,7 +2023,7 @@ else if ( _widec > _JSON_object_cond_keys[_mid+1] ) switch ( _JSON_object_cond_spaces[_JSON_object_cond_offsets[cs] + ((_mid - _keys)>>1)] ) { case 0: { _widec = 65536 + (data[p] - 0); - if ( + if ( // line 665 "ParserConfig.rl" config.allowTrailingComma ) _widec += 65536; break; @@ -2083,7 +2083,7 @@ else if ( _widec > _JSON_object_trans_keys[_mid+1] ) } } while (false); - _trans = _JSON_object_indicies[_trans]; + _trans = _JSON_object_indices[_trans]; cs = _JSON_object_trans_targs[_trans]; if ( _JSON_object_trans_actions[_trans] != 0 ) { @@ -2174,7 +2174,7 @@ else if ( _widec > _JSON_object_trans_keys[_mid+1] ) res.update(config.onLoad(context, result), p + 1); } - + // line 2179 "ParserConfig.java" private static byte[] init__JSON_actions_0() { @@ -2238,7 +2238,7 @@ private static byte[] init__JSON_index_offsets_0() private static final byte _JSON_index_offsets[] = init__JSON_index_offsets_0(); -private static byte[] init__JSON_indicies_0() +private static byte[] init__JSON_indices_0() { return new byte [] { 0, 0, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, @@ -2248,7 +2248,7 @@ private static byte[] init__JSON_indicies_0() }; } -private static final byte _JSON_indicies[] = init__JSON_indicies_0(); +private static final byte _JSON_indices[] = init__JSON_indices_0(); private static byte[] init__JSON_trans_targs_0() @@ -2287,7 +2287,7 @@ public IRubyObject parseImplementation(ThreadContext context) { IRubyObject result = null; ParserResult res = new ParserResult(); - + // line 2292 "ParserConfig.java" { cs = JSON_start; @@ -2296,7 +2296,7 @@ public IRubyObject parseImplementation(ThreadContext context) { // line 776 "ParserConfig.rl" p = byteList.begin(); pe = p + byteList.length(); - + // line 2301 "ParserConfig.java" { int _klen; @@ -2367,7 +2367,7 @@ else if ( data[p] > _JSON_trans_keys[_mid+1] ) } } while (false); - _trans = _JSON_indicies[_trans]; + _trans = _JSON_indices[_trans]; cs = _JSON_trans_targs[_trans]; if ( _JSON_trans_actions[_trans] != 0 ) { diff --git a/lib/json.rb b/lib/json.rb index 735f23806..0ebff2f94 100644 --- a/lib/json.rb +++ b/lib/json.rb @@ -133,7 +133,7 @@ # When not specified: # # The last value is used and a deprecation warning emitted. # JSON.parse('{"a": 1, "a":2}') => {"a" => 2} -# # waring: detected duplicate keys in JSON object. +# # warning: detected duplicate keys in JSON object. # # This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true` # # When set to `+true+` diff --git a/lib/json/common.rb b/lib/json/common.rb index 9a878cead..e99d152a8 100644 --- a/lib/json/common.rb +++ b/lib/json/common.rb @@ -1002,7 +1002,7 @@ class Coder # See {Parsing Options}[#module-JSON-label-Parsing+Options], and {Generating Options}[#module-JSON-label-Generating+Options]. # # For generation, the strict: true option is always set. When a Ruby object with no native \JSON counterpart is - # encoutered, the block provided to the initialize method is invoked, and must return a Ruby object that has a native + # encountered, the block provided to the initialize method is invoked, and must return a Ruby object that has a native # \JSON counterpart: # # module MyApp diff --git a/test/json/ractor_test.rb b/test/json/ractor_test.rb index dda34c64c..0ebdb0e91 100644 --- a/test/json/ractor_test.rb +++ b/test/json/ractor_test.rb @@ -42,7 +42,7 @@ def test_generate else puts "Expected:" puts expected_json - puts "Acutual:" + puts "Actual:" puts actual_json puts exit 1