From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: libnettle/libhogweed WIP Date: Sat, 15 Apr 2017 23:37:57 -0400 Message-ID: References: <83a89gq3us.fsf@gnu.org> <87bmtjiv0w.fsf_-_@lifelogs.com> <83o9xjn06c.fsf@gnu.org> <87shmeb5ln.fsf_-_@lifelogs.com> <83y3w5z1ez.fsf@gnu.org> <87lgr6yakj.fsf@lifelogs.com> <87wpamww9k.fsf@lifelogs.com> <8337daggnj.fsf@gnu.org> <87d1cdwxt6.fsf@lifelogs.com> <83tw5pg1q3.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1492313902 10482 195.159.176.226 (16 Apr 2017 03:38:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 16 Apr 2017 03:38:22 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 16 05:38:18 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1czb10-0002ct-3C for ged-emacs-devel@m.gmane.org; Sun, 16 Apr 2017 05:38:18 +0200 Original-Received: from localhost ([::1]:58983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1czb15-0003C6-Ty for ged-emacs-devel@m.gmane.org; Sat, 15 Apr 2017 23:38:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1czb0t-0003BG-UO for emacs-devel@gnu.org; Sat, 15 Apr 2017 23:38:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1czb0p-0005y4-33 for emacs-devel@gnu.org; Sat, 15 Apr 2017 23:38:11 -0400 Original-Received: from [195.159.176.226] (port=34152 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1czb0o-0005wx-SO for emacs-devel@gnu.org; Sat, 15 Apr 2017 23:38:07 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1czb0g-0002HG-G3 for emacs-devel@gnu.org; Sun, 16 Apr 2017 05:37:58 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 21 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:GujaZSPke/AM9HGxSFtfMumXwd4= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:213988 Archived-At: > I think STRING_SET_CHARS is what you want here. Really? This sets ->size without changing ->size_bytes, so it doesn't look right. I think we don't have the function that Ted wants. Basically, we'd need to provide a `resize_string_data` function, which will have to massage the sdata blocks appropriately, paying attention to LARGE_STRING_BYTES and things like that. I think when shrinking the string, we can avoid copying in most cases, but IIUC there are some cases where we can't avoid it (when the string is smaller than LARGE_STRING_BYTES and we shrink it by too few bytes to be able to place a new (free) sdata block in the freed space. This said, it could get a bit ugly around the LARGE_STRING_BYTES boundary because I can't see an easy way to efficiently figure out if a string data was allocated into a large_sblock(s) or into a small block (kept in oldest_sblock instead) so if the old size was larger than LARGE_STRING_BYTES but the new size is smaller, we may have to add a dummy "free sdata" as well (which again is only possible if the shrinkage is sufficient to make room for such a dummy sdata)). Stefan