summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/string.c b/string.c
index 248813e233..67f4f8dcc3 100644
--- a/string.c
+++ b/string.c
@@ -1807,16 +1807,16 @@ rb_str_reverse_bang(str)
char *s, *e;
char c;
- if (RSTRING(str)->len <= 1) return Qnil;
- rb_str_modify(str);
- s = RSTRING(str)->ptr;
- e = s + RSTRING(str)->len - 1;
- while (s < e) {
- c = *s;
- *s++ = *e;
- *e-- = c;
+ if (RSTRING(str)->len > 1) {
+ rb_str_modify(str);
+ s = RSTRING(str)->ptr;
+ e = s + RSTRING(str)->len - 1;
+ while (s < e) {
+ c = *s;
+ *s++ = *e;
+ *e-- = c;
+ }
}
-
return str;
}