From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 86668 invoked by alias); 12 Aug 2017 08:11:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 86008 invoked by uid 89); 12 Aug 2017 08:11:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=bigo, thousands X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 12 Aug 2017 08:10:59 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id v7C8AqKA032334 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 12 Aug 2017 04:10:57 -0400 Received: by simark.ca (Postfix, from userid 112) id D4E321EA1C; Sat, 12 Aug 2017 04:10:52 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 706491E043; Sat, 12 Aug 2017 04:10:28 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 12 Aug 2017 08:11:00 -0000 From: Simon Marchi To: Sergio Durigan Junior Cc: GDB Patches , Pedro Alves , Eli Zaretskii Subject: Re: [PATCH v2] Implement the ability to set/unset environment variables to GDBserver when starting the inferior In-Reply-To: <8760dt76c4.fsf@redhat.com> References: <20170629194106.23070-1-sergiodj@redhat.com> <20170727033531.23066-1-sergiodj@redhat.com> <87shhc9ffa.fsf@redhat.com> <291aec4022448984a38891ddbccf08e1@polymtl.ca> <87mv7f7x6t.fsf@redhat.com> <7be6bdecb0da90c8b2efb550fc017a5e@polymtl.ca> <8760dt76c4.fsf@redhat.com> Message-ID: <3bf8a362f32bcd1df388c62e7cd7ab51@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sat, 12 Aug 2017 08:10:53 +0000 X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00263.txt.bz2 On 2017-08-12 06:33, Sergio Durigan Junior wrote: >> Actually, if we expected the user to set thousands of environment >> variables and needed it to be fast to set and unset variables, it >> would be good to use std::set because of the O(log(N)) >> lookups/insertions/removals, which matters more when you have a lot of >> elements. But when you just have a few elements, the constant cost is >> more significant. A vector-based set would have O(N) complexity for >> these operations (at least for insertions and removals, for lookups it >> depends if it is sorted), which would be bad if we had thousands of >> elements. But since we expect to have just a few, it would likely be >> faster than std::set's constant cost. > > You mean std::vector's constant cost, right? No, I meant std::set's constant cost, although it wasn't clear. I meant the constant hidden by the big-O notation. The complexity of removing from a set may be O(log(N)), but we could also write it as "C1 * log(N)", where C1 is a constant. For a vector, it would take "C2 * N", where C2 is a constant. If C1 is much larger than C2, then using a set only starts being interesting with large Ns. That does a much better job at explaining than I do: http://lafstern.org/matt/col1.pdf Thanks, Simon