all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: Huge file adventure (+patch)
Date: Mon, 07 Oct 2013 11:15:41 -0400	[thread overview]
Message-ID: <jwvob7186ay.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <5252832E.5060804@yandex.ru> (Dmitry Antipov's message of "Mon, 07 Oct 2013 13:47:26 +0400")

> And, of course, there is a patch to address an issues described above.
> Comments are very welcome because I'm not hooked too much in coding
> machinery (yet).

Sounds good, in general.

>        else
>  	{
> -	  coding->dst_object
> -	    = make_unibyte_string ((char *) coding->destination,
> -				   coding->produced);
> -	  xfree (coding->destination);
> +	  /* This is used to avoid creating huge Lisp string.
> +	     NOTE: caller who set `raw_destination' is also
> +	     responsible to free `destination' buffer.  */
> +	  if (coding->raw_destination)
> +	    coding->dst_object = Qnil;
> +	  else
> +	    {
> +	      coding->dst_object
> +		= make_unibyte_string ((char *) coding->destination,
> +				       coding->produced);
> +	      xfree (coding->destination);
> +	    }
>  	}
>      }
 
You can remove the { between "else" and "if" (with the side-benefit that
the unchanged code will stay at the same indentation level).

>  	  if (CODING_REQUIRE_ENCODING (coding))
>  	    {
> -	      encode_coding_object (coding, string,
> -				    start, string_char_to_byte (string, start),
> -				    end, string_char_to_byte (string, end), Qt);
> +	      ptrdiff_t nchars = min (end - start, E_WRITE_MAX);
> +
> +	      /* Avoid creating huge Lisp string in encode_coding_object.  */
> +	      if (nchars == E_WRITE_MAX)
> +		coding->raw_destination = 1;
> +
> +	      encode_coding_object
> +		(coding, string, start, string_char_to_byte (string, start),
> +		 start + nchars, string_char_to_byte (string, start + nchars),
> +		 Qt);
>  	    }

Where/how do you make sure we loop back here for the rest
(when end-start > E_WRITE_MAX) ?


        Stefan



  reply	other threads:[~2013-10-07 15:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-07  9:47 Huge file adventure (+patch) Dmitry Antipov
2013-10-07 15:15 ` Stefan Monnier [this message]
2013-10-07 16:03   ` Dmitry Antipov
2013-10-07 19:03     ` Stefan Monnier
2013-10-07 16:07 ` Eli Zaretskii
2013-10-07 17:07   ` Dmitry Antipov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvob7186ay.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=dmantipov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.