summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2022-07-25 10:21:38 +0200
committerJean Boussier <jean.boussier@gmail.com>2022-08-18 10:09:08 +0200
commitb0b9f7201acab05c2a3ad92c3043a1f01df3e17f (patch)
treefe3445ca10f4254baab7e5c182eaccb1943e3b3b /file.c
parentfe61cad7490da8a879597f851f4a89856d44838e (diff)
rb_str_resize: Only clear coderange on truncation
If we are expanding the string or only stripping extra capacity then coderange won't change, so clearing it is wasteful.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6178
Diffstat (limited to 'file.c')
-rw-r--r--file.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/file.c b/file.c
index 5265d3a3a5..92338bb754 100644
--- a/file.c
+++ b/file.c
@@ -4090,6 +4090,9 @@ static VALUE
str_shrink(VALUE str)
{
rb_str_resize(str, RSTRING_LEN(str));
+ // expand_path on Windows can sometimes mutate the string
+ // without clearing its coderange
+ ENC_CODERANGE_CLEAR(str);
return str;
}