From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Wiegley Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 605f901: Prefer memcpy and memset to doing it by hand Date: Sun, 07 Feb 2016 12:53:29 -0500 Message-ID: References: <20160205003917.14369.86929@vcs.savannah.gnu.org> Reply-To: John Wiegley NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1454867873 13831 80.91.229.3 (7 Feb 2016 17:57:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 7 Feb 2016 17:57:53 +0000 (UTC) Cc: Paul Eggert , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Feb 07 18:57:46 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aSTai-0003Mx-Qb for ged-emacs-devel@m.gmane.org; Sun, 07 Feb 2016 18:57:45 +0100 Original-Received: from localhost ([::1]:36820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSTai-0005Az-0a for ged-emacs-devel@m.gmane.org; Sun, 07 Feb 2016 12:57:44 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSTad-00059a-Sx for emacs-devel@gnu.org; Sun, 07 Feb 2016 12:57:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSTac-00042r-NA for emacs-devel@gnu.org; Sun, 07 Feb 2016 12:57:39 -0500 Original-Received: from mail-ig0-x22c.google.com ([2607:f8b0:4001:c05::22c]:35435) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSTac-00042l-IQ for emacs-devel@gnu.org; Sun, 07 Feb 2016 12:57:38 -0500 Original-Received: by mail-ig0-x22c.google.com with SMTP id hb3so43117840igb.0 for ; Sun, 07 Feb 2016 09:57:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:in-reply-to:date:message-id:references :user-agent:reply-to:mail-followup-to:mime-version:content-type; bh=c5m619XK511gdIkLAYiTgNy8x02ZY3QVSTv3648FD0g=; b=w6gtmyl7kmU1ESftBiTirSxV2UAggVe8yYueAKVORVVO9YBM87U7untsaj4hzLV9UK PFCmN2ICyPkah9bGxurvc5udjqqTJ4YHD7155r87pH60JRxkyS360n17C/1JMARR/ihY j+i8b5d7+ItWH752SEMmoCT5yYJYm1xkaweSH1ZQXYT7BwNSNiItqT8UQhuIgfYD1HTA cvzS04h65fN9ckf4bFrN+WKvEz0baA9G7XN7oyfI7gux4PDXojSMogDQFcSNliHIg9eV wuOm2EfgDyVvxSDjblniVAl8GYwj7qtLwpWuyzLkbfrKdTtLdPXnreo1K8PGP7EmYke/ RBNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:in-reply-to:date:message-id :references:user-agent:reply-to:mail-followup-to:mime-version :content-type; bh=c5m619XK511gdIkLAYiTgNy8x02ZY3QVSTv3648FD0g=; b=mHEwgmE3I7wqeoo8GSDJBPethBCyjbzX8tyblOjqad+JGwhrpsccgFuHUCIUy6Skya uISVacF7J8keWFDPHqQeQZOhD0pyKXGg8viMi1qFT1otGPQfcLvIZjVLnYwfeKIZqebY POWSZrzV4Ym31hyO70fA+QzPKkkewJevrqtHn6fSga9m7NWWPEhYn3n4jItAxgTpn/NE W7I57FnQb5ykEiqYobk52XOHVReCnbP4ITPYo6AYWM5Q1P39LN02Iropsug0WTH+OMUh ws3rlbUHRh+YegagbYg4LuQxJUurNEa3d69DEG6hNKcKArbm9WAyf4blcvcUHf+YD3B2 flxg== X-Gm-Message-State: AG10YOT7h60o4hgiqyFXqeBZaTmAMw1vmYwOiWKaPNDNFithkNfzxZ+v+7ttVMGLUGWWNA== X-Received: by 10.50.134.2 with SMTP id pg2mr18967961igb.7.1454867858082; Sun, 07 Feb 2016 09:57:38 -0800 (PST) Original-Received: from Hermes.local (mail.johnwiegley.com. [208.82.103.192]) by smtp.gmail.com with ESMTPSA id p8sm3688773iga.10.2016.02.07.09.57.34 (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 07 Feb 2016 09:57:36 -0800 (PST) X-Google-Original-From: "John Wiegley" Original-Received: by Hermes.local (Postfix, from userid 501) id 19E094DD0FB7; Sun, 7 Feb 2016 12:57:32 -0500 (EST) In-Reply-To: (Stefan Monnier's message of "Fri, 05 Feb 2016 08:25:11 -0500") User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/24.5 (darwin) Mail-Followup-To: Stefan Monnier , emacs-devel@gnu.org, Paul Eggert X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4001:c05::22c X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:199452 Archived-At: >>>>> Stefan Monnier writes: >> + if (XLI (init) == 0) >> + memset (p->contents, 0, XFASTINT (length) * sizeof p->contents[0]); >> + else >> + for (ptrdiff_t i = 0; i < XFASTINT (length); i++) >> + p->contents[i] = init; > FWIW, I much prefer keeping just the loop, over using this "if+memset" which > seems like an obvious case or too-early-optimization. Is this so performance critical that we can't just always use the memset? Don't modern compilers inline the memset into the loop these days? -- John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2