[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 04/18: bytevector-slice: optimize trivial case
From: |
Andy Wingo |
Subject: |
[Guile-commits] 04/18: bytevector-slice: optimize trivial case |
Date: |
Thu, 8 Jun 2023 04:26:41 -0400 (EDT) |
wingo pushed a commit to branch main
in repository guile.
commit 67dbc60e8f5a839aaaf3b218744d026165ac1cdf
Author: Andy Wingo <wingo@pobox.com>
AuthorDate: Thu Jun 8 09:01:59 2023 +0200
bytevector-slice: optimize trivial case
* libguile/bytevectors.c (scm_bytevector_slice): Return the bytevector
directly if start==0 and count==len.
---
libguile/bytevectors.c | 3 +++
1 file changed, 3 insertions(+)
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);
- [Guile-commits] branch main updated (cd57379b3 -> 02dfb6e77), Andy Wingo, 2023/06/08
- [Guile-commits] 03/18: pretty-print: inline some handling of read macros, Andy Wingo, 2023/06/08
- [Guile-commits] 05/18: Add "custom ports", Andy Wingo, 2023/06/08
- [Guile-commits] 06/18: Rewrite custom binary ports in Scheme, in terms of custom ports, Andy Wingo, 2023/06/08
- [Guile-commits] 08/18: Rewrite soft ports in Scheme, Andy Wingo, 2023/06/08
- [Guile-commits] 04/18: bytevector-slice: optimize trivial case,
Andy Wingo <=
- [Guile-commits] 16/18: Load (ice-9 binary-ports) from C in thread-safe way, Andy Wingo, 2023/06/08
- [Guile-commits] 07/18: Use custom binary output ports for make-chunked-output-port, Andy Wingo, 2023/06/08
- [Guile-commits] 13/18: Inline generic-write into pretty-print, Andy Wingo, 2023/06/08
- [Guile-commits] 10/18: Modernize soft ports, Andy Wingo, 2023/06/08
- [Guile-commits] 01/18: pretty-print: Use string-concatenate-reverse, Andy Wingo, 2023/06/08
- [Guile-commits] 17/18: Deprecate (ice-9 lineio), Andy Wingo, 2023/06/08
- [Guile-commits] 18/18: Fix exn dispatch for exns within pre-unwind handlers, Andy Wingo, 2023/06/08
- [Guile-commits] 09/18: Implement R6RS custom textual ports, Andy Wingo, 2023/06/08
- [Guile-commits] 11/18: Rewrite pretty-print to rely on port-column, abort early, Andy Wingo, 2023/06/08
- [Guile-commits] 14/18: truncated-print: use call-with-truncating-output-string, Andy Wingo, 2023/06/08