Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions benchmark/time_now.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
benchmark:
- 'Time.now'
- 'Time.now(in: "+09:00")'
- 'Time.now.year'
20 changes: 12 additions & 8 deletions pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ def pack(fmt, buffer: nil)
end

class String
# call-seq:
# unpack(template, offset: 0, &block) -> array
# call-seq:
# unpack(template, offset: 0) {|o| .... } -> object
# unpack(template, offset: 0) -> array
#
# Extracts data from +self+.
# Extracts data from +self+ to form new objects;
# see {Packed Data}[rdoc-ref:packed_data.rdoc].
#
# If +block+ is not given, forming objects that become the elements
# of a new array, and returns that array. Otherwise, yields each
# object.
# With a block given, calls the block with each unpacked object.
#
# See {Packed Data}[rdoc-ref:packed_data.rdoc].
# With no block given, returns an array containing the unpacked objects.
#
# Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non--5CString].
def unpack(fmt, offset: 0)
Primitive.attr! :use_block
Primitive.pack_unpack(fmt, offset)
Expand All @@ -28,8 +30,10 @@ def unpack(fmt, offset: 0)
# call-seq:
# unpack1(template, offset: 0) -> object
#
# Like String#unpack, but unpacks and returns only the first extracted object.
# Like String#unpack with no block, but unpacks and returns only the first extracted object.
# See {Packed Data}[rdoc-ref:packed_data.rdoc].
#
# Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non--5CString].
def unpack1(fmt, offset: 0)
Primitive.pack_unpack1(fmt, offset)
end
Expand Down
14 changes: 7 additions & 7 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -11972,9 +11972,9 @@ rb_str_unicode_normalize(int argc, VALUE *argv, VALUE str)
* unicode_normalize!(form = :nfc) -> self
*
* Like String#unicode_normalize, except that the normalization
* is performed on +self+.
* is performed on +self+ (not on a copy of +self+).
*
* Related String#unicode_normalized?.
* Related: see {Modifying}[rdoc-ref:String@Modifying].
*
*/
static VALUE
Expand All @@ -11986,8 +11986,9 @@ rb_str_unicode_normalize_bang(int argc, VALUE *argv, VALUE str)
/* call-seq:
* unicode_normalized?(form = :nfc) -> true or false
*
* Returns +true+ if +self+ is in the given +form+ of Unicode normalization,
* +false+ otherwise.
* Returns whether +self+ is in the given +form+ of Unicode normalization;
* see String#unicode_normalize.
*
* The +form+ must be one of +:nfc+, +:nfd+, +:nfkc+, or +:nfkd+.
*
* Examples:
Expand All @@ -12001,10 +12002,9 @@ rb_str_unicode_normalize_bang(int argc, VALUE *argv, VALUE str)
* Raises an exception if +self+ is not in a Unicode encoding:
*
* s = "\xE0".force_encoding(Encoding::ISO_8859_1)
* s.unicode_normalized? # Raises Encoding::CompatibilityError.
*
* Related: String#unicode_normalize, String#unicode_normalize!.
* s.unicode_normalized? # Raises Encoding::CompatibilityError
*
* Related: see {Querying}[rdoc-ref:String@Querying].
*/
static VALUE
rb_str_unicode_normalized_p(int argc, VALUE *argv, VALUE str)
Expand Down
9 changes: 4 additions & 5 deletions time.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,6 @@ zone_str(const char *zone)
{
const char *p;
int ascii_only = 1;
VALUE str;
size_t len;

if (zone == NULL) {
Expand All @@ -997,18 +996,18 @@ zone_str(const char *zone)
}
len = p - zone;
if (ascii_only) {
str = rb_usascii_str_new(zone, len);
return rb_enc_interned_str(zone, len, rb_usascii_encoding());
}
else {
#ifdef _WIN32
str = rb_utf8_str_new(zone, len);
VALUE str = rb_utf8_str_new(zone, len);
/* until we move to UTF-8 on Windows completely */
str = rb_str_export_locale(str);
return rb_fstring(str);
#else
str = rb_enc_str_new(zone, len, rb_locale_encoding());
return rb_enc_interned_str(zone, len, rb_locale_encoding());
#endif
}
return rb_fstring(str);
}

static void
Expand Down
9 changes: 6 additions & 3 deletions vm_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ rb_vmdebug_thread_dump_state(FILE *errout, VALUE self)
# include <sys/mman.h>
# undef backtrace

# if defined(__arm64__)
# if defined(__arm64__) || defined(__POWERPC__)
static bool
is_coroutine_start(unw_word_t ip)
{
Expand Down Expand Up @@ -879,19 +879,22 @@ backtrace(void **trace, int size)
}
return n;

# elif defined(__arm64__)
# elif defined(__arm64__) || defined(__POWERPC__)
/* Since Darwin arm64's _sigtramp is implemented as normal function,
* unwind can unwind frames without special code.
* https://github.com/apple/darwin-libplatform/blob/215b09856ab5765b7462a91be7076183076600df/src/setjmp/generic/sigtramp.c
*/
while (unw_step(&cursor) > 0) {
unw_get_reg(&cursor, UNW_REG_IP, &ip);
# if defined(__arm64__)
// Strip Arm64's pointer authentication.
// https://developer.apple.com/documentation/security/preparing_your_app_to_work_with_pointer_authentication
// I wish I could use "ptrauth_strip()" but I get an error:
// "this target does not support pointer authentication"
trace[n++] = (void *)(ip & 0x7fffffffffffull);

# else
trace[n++] = (void *)ip;
# endif
// Apple's libunwind can't handle our coroutine switching code
if (is_coroutine_start(ip)) break;
}
Expand Down