Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsxqy-0001Wf-HY for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Jul 2019 23:17:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hsxqw-00084E-SE for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Jul 2019 23:17:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsxqw-0007xO-EM for pgsql-hackers@lists.postgresql.org; Wed, 31 Jul 2019 23:17:50 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsxqo-0000Qe-CD for pgsql-hackers@lists.postgresql.org; Wed, 31 Jul 2019 23:17:49 +0000 Received: by mail-wm1-x341.google.com with SMTP id l2so61346206wmg.0 for ; Wed, 31 Jul 2019 16:17:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=wbLmOzSytndsbn2z/rzG9n9+oHOS94boq+SDDd1ck88=; b=G+zdWGRJF/n+CH9hywYPTVpL6pZPrEfsOuSRtx5HxvfyKzIH5K6XoiEf4Oj+GWUPyU +K1aHeLRWX5KOPlnghiSUSiINL5AMyu0iaZyn1EE/D+sY40OTlDIV0sja1cN66Mg+DB7 +HXIYqCMKqidgene/v/8Q1IB1Ec6x1vfK/rxyCLj7HRUusVMj3VKrzgftoQy1bboNFTa zymhrDdwagUzhOif8RTyL0Z1h0LQvwQIWzdkvN8AE23Dsug0bTa6Xx8N7CwXQbsO8B4Y UIExISci2Qkpgv6En09qbuEvRGKQvVWtAOMQF9yzSAe9Uwavk1mvzVp0UVxapLefcj5G XNmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=wbLmOzSytndsbn2z/rzG9n9+oHOS94boq+SDDd1ck88=; b=lOh7lyv6VtL2V19Swqq+IAvcumOvtSb9NA8nW1TCMNGdHZ62ey2EcxYjzJXFTZomEg AGAYHNKcs2K9Kc+u9nqyRGljGy4KWmXteKlG7ViFJPX+5YctUJbgDYJ3a/4zHltqVOrf vQahbksV/5iyFgQ80pLgOslPZzhM0ucirqpaYnj5Xd2aPBWk6t91ZZe/EZkICxluhTMk X6DWwHCSirJcHHEzBTsoQGxuOZ7fh3fOlN1WODicMxMVXurJvtttgafCY0eJ7gbaxpS2 9Xld6a+mgm7igfv13q72vivEGKF1J+J5zzuaatAioV9BeNBFyHTbwe6czfMHJl8ExZzQ A2Rg== X-Gm-Message-State: APjAAAXWsBAMCMmHOhL9uBVOOgyBV8Qk5hrlw7TRjhBQJ86TiGeycDDY 2Jd1y345AS/RoG3wEKsaByCo9kycIMdP3xwKBKE6CD3CY5qXA8vSZ+K2Xwbx9yEf8gOYuh1w++6 oqcrvbqNsX/+pjCK7JyjxQDJQE4xXhyv5HvJqcXXBuEqLIddz1lGs+lzz4xmrHdwunWoryi8qmX rZtw8yz9PG/TM= X-Google-Smtp-Source: APXvYqwjATXW/kS37i8auR5CT46GzlOCjVrrZSCMmT1Jq6RJ6dsVDUyxakq0iYuVWr9R98zL5/UWLw== X-Received: by 2002:a1c:238e:: with SMTP id j136mr109872055wmj.144.1564615058560; Wed, 31 Jul 2019 16:17:38 -0700 (PDT) Received: from ?IPv6:2a02:8308:13b:9400:3de1:b743:7509:76c9? ([2a02:8308:13b:9400:3de1:b743:7509:76c9]) by smtp.gmail.com with ESMTPSA id u186sm124997531wmu.26.2019.07.31.16.17.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jul 2019 16:17:38 -0700 (PDT) Subject: Re: POC: converting Lists into arrays To: Andres Freund , Tom Lane Cc: pgsql-hackers@lists.postgresql.org References: <11587.1550975080@sss.pgh.pa.us> <20190731225756.nozn3j6lgwhm6qvq@alap3.anarazel.de> <20190731230047.xtbgswuwopmrhd53@alap3.anarazel.de> <20190731230403.ytizwaji7gvof7x3@alap3.anarazel.de> From: Petr Jelinek Message-ID: Date: Thu, 1 Aug 2019 01:17:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190731230403.ytizwaji7gvof7x3@alap3.anarazel.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 01/08/2019 01:04, Andres Freund wrote: > Hi, > > On 2019-07-31 16:00:47 -0700, Andres Freund wrote: >> On 2019-07-31 15:57:56 -0700, Andres Freund wrote: >>> I also wonder if a foreach version that includes the typical >>> (Type *) var = (Type *) lfirst(lc); >>> or >>> (Type *) var = castNode(Type, lfirst(lc)); >>> or >>> OpExpr *hclause = lfirst_node(OpExpr, lc); >>> >>> would make it nicer to use lists. >>> >>> foreach_node_in(Type, name, list) could mean something like >>> >>> foreach(ListCell *name##_cell, list) >>> { >>> Type* name = lfirst_node(Type, name##_cell); >>> } >> >> s/lfirst/linitial/ of course. Was looking at code that also used >> lfirst... > > Bullshit, of course. > > /me performs a tactical withdrawal into his brown paper bag. > > >> Reminds me that one advantage of macros like the second one would also >> be to reduce the use of the confusingly named linitial*(), helping newer >> hackers. > > But that point just had two consecutive embarassing demonstrations... > Yeah, pg_list.h is one file I never close. -- Petr Jelinek 2ndQuadrant - PostgreSQL Solutions for the Enterprise https://www.2ndQuadrant.com/