From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.devel Subject: Re: How to quickly compare equality of structs ... Date: Mon, 06 May 2019 13:40:07 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="10248"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 06 22:40:52 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hNkPs-0002ZH-Jp for ged-emacs-devel@m.gmane.org; Mon, 06 May 2019 22:40:52 +0200 Original-Received: from localhost ([127.0.0.1]:33769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNkPr-0006r0-HL for ged-emacs-devel@m.gmane.org; Mon, 06 May 2019 16:40:51 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:54029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNkPD-0006os-Nz for emacs-devel@gnu.org; Mon, 06 May 2019 16:40:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hNkPC-0006zW-Fx for emacs-devel@gnu.org; Mon, 06 May 2019 16:40:11 -0400 Original-Received: from gateway22.websitewelcome.com ([192.185.47.168]:27057) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hNkPC-0006w7-1u for emacs-devel@gnu.org; Mon, 06 May 2019 16:40:10 -0400 Original-Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 1206512243 for ; Mon, 6 May 2019 15:40:09 -0500 (CDT) Original-Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP id NkPAhfT4a2PzONkPAh7tgw; Mon, 06 May 2019 15:40:09 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com ; s=default; h=Content-Type:MIME-Version:Subject:Cc:To:From:Message-ID:Date: Sender:Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=klFTZSeOGUHGpVGet6zC65G5SEboc5ri9WehckypaSw=; b=AG/LdTPbNpgsyDQWZt4Y52RiHm JYxWqA+IdI46VHIKkkUY3HC0GB0fk3u+GTzfv9TDP1aPSTsqEGxM5gLynhTGWE0N9i6Rhq93CAflh 3DViZ9cQaU3Wh4u876LA2+ZJqFn6yhdRb0Yc9aeRrv08BSMzcbZKQnpFbEb0hubctkhoZDE7pjQMb ICanovB6N3lhFjyLODptsg4ZQ9Xz5Q5q6UY0KM+MvDpazcp1H9WEuGXpwbtI/8pgBfBKD2trLItKn 2317OQ8kuzXXXqIqYthi2S+gVb8Jdkx+n5OKh7BkRaB2FV4kggC1uIsD/7ALKDk2yI3UopZHs8iok dngpEXlQ==; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:51170 helo=server.local) by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.91) (envelope-from ) id 1hNkPA-003AEz-9r; Mon, 06 May 2019 15:40:08 -0500 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3053.hostgator.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-BWhitelist: no X-Source-IP: 45.48.239.195 X-Source-L: No X-Exim-ID: 1hNkPA-003AEz-9r X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.local) [45.48.239.195]:51170 X-Source-Auth: lawlist X-Email-Count: 1 X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 192.185.47.168 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:236215 Archived-At: Thank you, Paul, for having a look at this particular thread. I had read on Stackoverflow that memcmp is not always reliable, and that is why I was trying to come up with a quick and guaranteed method of doing the comparison of data for each fake cursor in the new/old caches: https://stackoverflow.com/a/141791/2112489 In the accepted answer, it says that C provides no method for comparing equality of structs ... My only experience with a hash table has been in Lisp by setting up a unique key per each entry in the table; e.g., make-hash-table, gethash, puthash .... The old cache and new cache will most likely have a different number of fake cursors and the order in which they appear will also be different; e.g., 200 fake cursors in the old cache and 250 fake cursors in the new cache. Based on my limited experience with hash tables in Lisp, I am unable to visualize how I could use such a table in C to do my comparison for each fake cursor .... ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > Date: [05-06-2019 12:00:11] <6 May 2019 12:00:11 -0700> > From: Paul Eggert > To: Keith David Bershatsky > Cc: Emacs Devel > Subject: Re: How to quickly compare equality of structs ... > > On 5/6/19 11:55 AM, Keith David Bershatsky wrote: > > PROBLEM: If the tentative plan makes good sense, then how can I programmatically turn a combination of int, enum, double and bool into one (1) unique numeric representation such as a SHA1 (Secure Hash Algorithm)? > > It's not clear to me that hashing is needed here; why not just use > memcmp? And if you do need hashing, why not just use an ordinary hash > table rather than messing with cryptographic hashing?