From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id CDD027EE49 for ; Sun, 15 Sep 2013 12:38:52 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of jacques-henri.jourdan@ens.fr) identity=pra; client-ip=176.31.242.187; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jacques-henri.jourdan@ens.fr"; x-sender="jacques-henri.jourdan@ens.fr"; x-conformance=sidf_compatible Received-SPF: Neutral (mail3-smtp-sop.national.inria.fr: domain of jacques-henri.jourdan@ens.fr does not assert whether or not 176.31.242.187 is permitted sender) identity=mailfrom; client-ip=176.31.242.187; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jacques-henri.jourdan@ens.fr"; x-sender="jacques-henri.jourdan@ens.fr"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@ulminfo.fr) identity=helo; client-ip=176.31.242.187; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jacques-henri.jourdan@ens.fr"; x-sender="postmaster@ulminfo.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Am8BAGCNNVKwH/K7nGdsb2JhbABbwgSCdoEXFg4BAQEBAQgUCTyCJgEFeBELIRYPCQMCAQIBRRMIAQGIA7lpjiCBWhaECAOQJoEvjFaOaoFv X-IPAS-Result: Am8BAGCNNVKwH/K7nGdsb2JhbABbwgSCdoEXFg4BAQEBAQgUCTyCJgEFeBELIRYPCQMCAQIBRRMIAQGIA7lpjiCBWhaECAOQJoEvjFaOaoFv X-IronPort-AV: E=Sophos;i="4.90,909,1371074400"; d="asc'?scan'208";a="26896630" Received: from ulminfo.fr ([176.31.242.187]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 15 Sep 2013 12:38:52 +0200 Received: from [192.168.1.20] (ALille-652-1-130-3.w83-198.abo.wanadoo.fr [83.198.81.3]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ulminfo.fr (Postfix) with ESMTPSA id 8107540D3A for ; Sun, 15 Sep 2013 12:38:51 +0200 (CEST) Message-ID: <52358E3A.7030802@ens.fr> Date: Sun, 15 Sep 2013 12:38:50 +0200 From: Jacques-Henri Jourdan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 MIME-Version: 1.0 To: caml-list@inria.fr References: <20130915103027.GA21344@jrm> In-Reply-To: <20130915103027.GA21344@jrm> X-Enigmail-Version: 1.5.2 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="KtX0jd1UpD7403Vj6CQAHhXbUUmCVLpTw" Subject: Re: [Caml-list] Accessing record fields This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --KtX0jd1UpD7403Vj6CQAHhXbUUmCVLpTw Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I think both are very close. I would say that f is faster, because r.a is loaded only once. However, this can increase register pressure... I would say to use whichever is more easy to use a a given context, and to tune specifically the code if this is the bottleneck: this is very unlikely to be the performance bottleneck, and there won't be a big performance improvement anyway... --=20 JH Le 15/09/2013 12:30, Jos=E9 Romildo Malaquias a =E9crit : > Hello. >=20 > OCaml offers at least two ways of accessing a record field: using the > dot notation, and doing pattern matching. >=20 > Does one of them deliver better performance than the other? >=20 > This may be relevant when a field is accessed multiple times. >=20 > For instance: >=20 > type trec =3D { a : int; mutable b: int } >=20 > let f {a;b} =3D a * a + b >=20 > let g r =3D r.a * r.a + r.b >=20 > Which one would be preferred in this case: f or g? >=20 > Romildo >=20 --KtX0jd1UpD7403Vj6CQAHhXbUUmCVLpTw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSNY46AAoJEGHoGlEY1GjFG70H/R501mpLGSbMASjBAyMWL74u ENEYFnq2oyCVXfZpCs+kNg8w+6aEYsS7QYQYTvKn8UixTGkXkflmRu0p7JWCCnoU hbZpAFT2/BL7hxaJoL8ikLvWOzYi85tm3IEdmt84pfIYHMNcZ0d/eYBYPr/nVtrB HzVp3UpRNRp+zA3H1TgjVvy2VKU8z57k9W/EjcOSGiOGq5RzrQZMLTYCAeBu655W qTx/GQRPSpJMJf7Ty46aiKHZ3itifppFcHGJ9k+/beWsv971Pbwgt3aIYm08nSLi tZ7qKz1ro3FJv44Fpf6Moq1ti+OExfGGRWCC+Ucw2P4NNd/ziXChX4HD8+kuwDc= =NCL/ -----END PGP SIGNATURE----- --KtX0jd1UpD7403Vj6CQAHhXbUUmCVLpTw--