fix string repeat tests

This commit is contained in:
Folkert 2022-02-20 00:47:07 +01:00
parent dea6cfbc8f
commit 2c4d0e71a6
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
5 changed files with 50 additions and 34 deletions

View file

@ -856,16 +856,17 @@ fn modify_refcount_str_help<'a, 'ctx, 'env>(
let parent = fn_val;
let str_wrapper = arg_val.into_struct_value();
let len = builder
.build_extract_value(str_wrapper, Builtin::WRAPPER_LEN, "read_str_ptr")
let capacity = builder
.build_extract_value(str_wrapper, Builtin::WRAPPER_CAPACITY, "read_str_capacity")
.unwrap()
.into_int_value();
// Small strings have 1 as the first bit of length, making them negative.
// Small strings have 1 as the first bit of capacity, making them negative.
// Thus, to check for big and non empty, just needs a signed len > 0.
let is_big_and_non_empty = builder.build_int_compare(
IntPredicate::SGT,
len,
capacity,
env.ptr_int().const_zero(),
"is_big_str",
);