aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2017-06-24 22:57:41 +0900
committerKazuki Yamaguchi <k@rhe.jp>2017-06-26 15:22:58 +0900
commitd9e4b1c9bb179466743d941dc45de5993a027599 (patch)
tree412e697c8f04eebc36c5c55b26edbca132663f3c
parent7e8ce63e8a3af23f56f47e240cf07b3dfa0bd291 (diff)
downloadruby-d9e4b1c9bb179466743d941dc45de5993a027599.tar.gz
string.c: remove a dead branch in str_fill_term()
The length of a string can never exceed the actual capacity returned by str_capacity().
-rw-r--r--string.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/string.c b/string.c
index 072f1329ee..22664febfd 100644
--- a/string.c
+++ b/string.c
@@ -2117,17 +2117,10 @@ str_null_char(const char *s, long len, const int minlen, rb_encoding *enc)
static char *
str_fill_term(VALUE str, char *s, long len, int termlen)
{
- long capa = str_capacity(str, termlen);
-
/* This function assumes that (capa + termlen) bytes of memory
* is allocated, like many other functions in this file.
*/
-
- if (capa < len) {
- rb_check_lockedtmp(str);
- str_make_independent_expand(str, len, 0L, termlen);
- }
- else if (str_dependent_p(str)) {
+ if (str_dependent_p(str)) {
if (!zero_filled(s + len, termlen))
str_make_independent_expand(str, len, 0L, termlen);
}