-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve scalar quoting performance #69
Conversation
The original implementation was based on Revisiting it now with Emacs 27.1, there's a crossover point between 3 and 4 apostrophes. The temp buffer has a high startup cost, but is overall more efficient (the gap buffer avoids generating garbage). ;;; -*- lexical-binding: t; -*-
(dotimes (i 25)
(let ((s (format "abc%sdef" (make-string i ?'))))
(benchmark 100000 (list 'emacsql-quote-scalar s)))) The regexp-replace version runs the garbage collector much more often: No matter the number of apostrophes, it spends most of its time in the garbage collector: Since most string scalars are expected to have fewer than 4 apostrophes, it probably makes sense just to use the replace-regexp version, but I'm still wary about the worst case and generating so much garbage. |
4bea632
to
97b866d
Compare
Thank you for the detailed insights and explanation of the historical reasons that led to the current implementation. Interestingly, the
|
c287c50
to
66206d7
Compare
66206d7
to
5f8aeb2
Compare
Results on my system:
Current:
PR: