From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Loading svg from memory using custom filename for base_uri Date: Sat, 23 Feb 2019 09:45:08 +0200 Message-ID: <83a7inq77f.fsf@gnu.org> References: Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="79209"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel@gnu.org To: Evgeny Zajcev Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 23 08:45:47 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gxS0J-000KUe-K9 for ged-emacs-devel@m.gmane.org; Sat, 23 Feb 2019 08:45:47 +0100 Original-Received: from localhost ([127.0.0.1]:34010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxS0I-0003YR-KH for ged-emacs-devel@m.gmane.org; Sat, 23 Feb 2019 02:45:46 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:55741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxRze-0003YB-Lw for emacs-devel@gnu.org; Sat, 23 Feb 2019 02:45:07 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:46749) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxRzd-0007jY-Bv; Sat, 23 Feb 2019 02:45:05 -0500 Original-Received: from [176.228.60.248] (port=2950 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gxRzc-0001nl-Vx; Sat, 23 Feb 2019 02:45:05 -0500 In-reply-to: (message from Evgeny Zajcev on Sat, 23 Feb 2019 01:01:02 +0300) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:233536 Archived-At: > From: Evgeny Zajcev > Date: Sat, 23 Feb 2019 01:01:02 +0300 > > Currently, when SVG image is loaded with `svg_load` it first examines :file value and only if :file is missing it > looks for :data, using current buffer's filename (if any) as base_uri > > Would not it be better to check for :data first and if present, then use :file as value for base_uri? Falling back > to current buffer filename in case :file is missing > > Unfortunately embedding raster images into svg with base64 encoding, using `svg-embed` is slow. I don't think I understand what you are saying here. The test whether an image spec specifies a file or not is just 2 lines of C: /* If IMG->spec specifies a file name, create a non-file spec from it. */ file_name = image_spec_value (img->spec, QCfile, NULL); if (STRINGP (file_name)) { [load an image from file...] } /* Else its not a file, it's a lisp object. Load the image from a lisp object rather than a file. */ else { [load an image from data...] } And image_spec_value just walks a Lisp list looking for ':file': static Lisp_Object image_spec_value (Lisp_Object spec, Lisp_Object key, bool *found) { Lisp_Object tail; eassert (valid_image_p (spec)); for (tail = XCDR (spec); CONSP (tail) && CONSP (XCDR (tail)); tail = XCDR (XCDR (tail))) { if (EQ (XCAR (tail), key)) { if (found) *found = 1; return XCAR (XCDR (tail)); } } So I don't see how reversing the order would speed up SVG loading. What did I miss?