From dc0e4ab5aeb76a0ec2d37267b49fd2348ef7c420 Mon Sep 17 00:00:00 2001 From: Bob131 Date: Thu, 2 Sep 2021 07:33:42 +1000 Subject: xapian: Reimplement document-bytes. The current implementation of document-bytes involves converting the document data string into a list of characters, mapping over the result with char->integer and passing the list of integers to u8-list->integer. This is quite an expensive operation (relative to what the user might expect), and may not reliably return a result if the document data couldn't be decoded as a UTF-8 string in the first place. Now that we have SWIG wrappers that return bytevectors directly, we can redefine document-bytes as an alias of Document-get-data-bytes. * xapian/xapian.scm (document-bytes): Redefine function in terms of Document-get-data-bytes. Signed-off-by: Arun Isaac --- xapian/xapian.scm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/xapian/xapian.scm b/xapian/xapian.scm index a0876d1..0e2e966 100644 --- a/xapian/xapian.scm +++ b/xapian/xapian.scm @@ -1,5 +1,6 @@ ;;; guile-xapian --- Guile bindings for Xapian ;;; Copyright © 2020 Arun Isaac +;;; Copyright © 2021 Bob131 ;;; ;;; This file is part of guile-xapian. ;;; @@ -94,10 +95,7 @@ in-memory database would always remain empty and is of little use." (define document-data Document-get-data) (define document-slot-ref Document-get-value) -(define (document-bytes document) - "Return the data of DOCUMENT as a bytevector." - (u8-list->bytevector - (map char->integer (string->list (document-data document))))) +(define document-bytes Document-get-data-bytes) (define make-stem new-Stem) -- cgit v1.2.3