From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.help Subject: Re: [External] : Passing buffers to function in elisp Date: Wed, 8 Mar 2023 06:38:54 +0100 Message-ID: References: <87mt56hg4e.fsf@iki.fi> <87bklihln8.fsf@iki.fi> <87pm9yf0ph.fsf@web.de> <87v8jmkfd0.fsf@iki.fi> <87jzzsjkrp.fsf@iki.fi> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="xT8Ufqi/O4sWqhLA" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39060"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 08 06:39:41 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZmWa-0009vH-QF for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 08 Mar 2023 06:39:40 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZmW5-0007Rq-CT; Wed, 08 Mar 2023 00:39:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZmW3-0007RO-HT for help-gnu-emacs@gnu.org; Wed, 08 Mar 2023 00:39:07 -0500 Original-Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZmVv-0005YX-DJ for help-gnu-emacs@gnu.org; Wed, 08 Mar 2023 00:39:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=OU2BkTYWoHSqGSF06OPwT/PRBbWYvu2VrHzBmqWd+2w=; b=g9ZoUPa5mdqqYmyXL0h0XovNDJ 7iCS5nOmziGpNW4FrKtq236DRe/D4ngIIDisd9pCiX0FjGjNB6rxBHFDY8/UlE/7yxTjwB1yxW9mV gyAP1+H3FkjRqJ2WrrlOmmeo25dUBCbfvg6asMjxJVzUdUVdV18dP3cLKDkpQt0iIpRDS0MLmccNM wgNCHLGsyBi3KY+zpzp/5gpBu6MKutLhcBX00eDLKLWKqzusM7wGwZjUXFPP3Tw5hFAU6geQ6QqFW ycXDKEE/k9QW3Kx9OQb8edgWliP8zm/OIZu0eJfDomDUH/aFW3OQO8XaJII4csIynF3lCAw6wUdWk fUs/Z1Lg==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1pZmVq-0005g3-Nx for help-gnu-emacs@gnu.org; Wed, 08 Mar 2023 06:38:54 +0100 Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:142945 Archived-At: --xT8Ufqi/O4sWqhLA Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 07, 2023 at 05:45:49PM -0500, Stefan Monnier wrote: > >> This is a typical a source of unnecessary O(N=C2=B2) complexity: the a= bove > >> line takes O(N) time, so if you do it O(N) times, you got your > >> N=C2=B2 blowup. You're usually better off doing > >> > >> (push (plist-get page :stream) stream-chunks) > >> > >> and then at the end get the `stream` with > >> > >> (mapconcat #'identity (nreverse stream-chunks) nil) > >> or > >> (apply #'vconcat (nreverse stream-chunks)) > > > > Right, I see. Stream chunks are in this case byte vectors, so > > just reversing those chunks does not do the trick. > > But surely I can get from an order of N=C2=B2 to 2N or so. >=20 > I'm suggesting to build a list of chunks backward and to reverse *the > list*, not the chunks. So the end result should still be the same. Judging by the "2N instead of N^2" I guess Petteri had the right mental model, though. > > Okay, this is something I did not foresee. But what about eval-defun > > and eval-... in general? They are very convenient when trying out > > things. >=20 > It's OK to use them, of course. It usually means you still have 98% of > your code compiled. >=20 > >> The compiler is your friend. He can help you get the code in good > >> shape :-) > > I'm afraid that even the compiler cannot help against quadratic > > complexity blunders. >=20 > :-) >=20 > It's just a friend, yes. :-) Cheers --=20 t --xT8Ufqi/O4sWqhLA Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZAgfZgAKCRAFyCz1etHa RtAMAJ43XACodM8+LpzN+8JRF6GpLmPqLQCfeNfn3wAsG+XidefkhhEoveAKARo= =YsPa -----END PGP SIGNATURE----- --xT8Ufqi/O4sWqhLA--