Skip to content

Commit a0305db

Browse files
stepanchegfacebook-github-bot
authored andcommitted
Assert alloc_str_concat is not called with empty strings
Summary: Documentation assertion. Reviewed By: ndmitchell Differential Revision: D30888590 fbshipit-source-id: ea686812f19770e016cfe56004560df6d0170bdf
1 parent b26b86c commit a0305db

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

starlark/src/values/layout/heap.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ impl Heap {
311311
}
312312

313313
pub(crate) fn alloc_str_concat<'v>(&'v self, x: &str, y: &str) -> Value<'v> {
314+
// If either strings is empty, we should not be calling this function
315+
// but reuse non-empty string object instead.
316+
debug_assert!(!x.is_empty());
317+
debug_assert!(!y.is_empty());
318+
314319
self.alloc_str_init(x.len() + y.len(), |dest| unsafe {
315320
copy_nonoverlapping(x.as_ptr(), dest, x.len());
316321
copy_nonoverlapping(y.as_ptr(), dest.add(x.len()), y.len())

0 commit comments

Comments
 (0)