diff options
author | Andy Wingo <wingo@pobox.com> | 2023-06-08 09:01:59 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2023-06-08 09:01:59 +0200 |
commit | 67dbc60e8f5a839aaaf3b218744d026165ac1cdf (patch) | |
tree | a17872e2acdbf0858e486c17e1efd6d52d9c1de0 /libguile/bytevectors.c | |
parent | 03344ce4318c0c712536b8167cbac4bf77e797be (diff) | |
download | guile-67dbc60e8f5a839aaaf3b218744d026165ac1cdf.tar.gz |
bytevector-slice: optimize trivial case
* libguile/bytevectors.c (scm_bytevector_slice): Return the bytevector
directly if start==0 and count==len.
Diffstat (limited to 'libguile/bytevectors.c')
-rw-r--r-- | libguile/bytevectors.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c index 6d9f6476d..6b14c7246 100644 --- a/libguile/bytevectors.c +++ b/libguile/bytevectors.c @@ -357,6 +357,9 @@ SCM_DEFINE (scm_bytevector_slice, "bytevector-slice", 2, 1, 0, else c_size = scm_to_size_t (size); + if (c_offset == 0 && c_size == SCM_BYTEVECTOR_LENGTH (bv)) + return bv; + if (INT_ADD_OVERFLOW (c_offset, c_size) || (c_offset + c_size > SCM_BYTEVECTOR_LENGTH (bv))) scm_out_of_range (FUNC_NAME, offset); |