emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loading svg from memory using custom filename for base_uri


From: Eli Zaretskii
Subject: Re: Loading svg from memory using custom filename for base_uri
Date: Sat, 23 Feb 2019 09:45:08 +0200

> From: Evgeny Zajcev <address@hidden>
> 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?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]