[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1484260 - /subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_client/diff.c

From: Daniel Shahaf <danielsh_at_apache.org>
Date: Mon, 20 May 2013 17:00:50 +0000

On Mon, May 20, 2013 at 04:29:30PM +0100, Gabriela Gibson wrote:
> On 19/05/13 17:48, Daniel Shahaf wrote:
> >On Sun, May 19, 2013 at 10:15:55AM -0000, gbg_at_apache.org wrote:
> >>Author: gbg
> >>Date: Sun May 19 10:15:55 2013
> >>New Revision: 1484260
> >>
> >>URL: http://svn.apache.org/r1484260
> >>Log:
> >>Seperate variable declaration from assigment.
> >>
> >>* subversion/libsvn_client/diff.c
> >> (set_up_diff_cmd_and_options): Seperate variable declaration from
> >> assigment.
> >>
> >>Modified:
> >> subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_client/diff.c
> >>
> >>Modified:
> >>subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_client/diff.c
> >>URL:
> >>http://svn.apache.org/viewvc/subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_client/diff.c?rev=1484260&r1=1484259&r2=1484260&view=diff
> >>==============================================================================
> >>---
> >>subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_client/diff.c (original)
> >>+++
> >>subversion/branches/invoke-diff-cmd-feature/subversion/libsvn_client/diff.c Sun May 19 10:15:55 2013
> >>@@ -2465,7 +2465,9 @@ set_up_diff_cmd_and_options(struct diff_
> >> /* old style diff_cmd has precedence in config file */
> >> if (config)
> >> {
> >>- svn_config_t *cfg = svn_hash_gets(config,
> >>SVN_CONFIG_CATEGORY_CONFIG);
> >>+ svn_config_t *cfg;
> >>+
> >>+ cfg = svn_hash_gets(config, SVN_CONFIG_CATEGORY_CONFIG);
> >
> >Why? This doesn't seem to serve any useful purpose (in fact, I think it
> >makes
> >the code harder to read).
> >
>
> Because (if I understood this correctly!) the compiler builds more
> efficient code and the startup time of the application is improved.
>

Check the machine code generated before and after your change; it will be the
same.

> "To summarize, it is always preferable to add variables
> as uninitialized or initialized with zero as opposed to as
> initialized with a value other than zero."
>
> See Page 16 here:
> http://software.intel.com/sites/default/files/m/a/1/e/dsohowto.pdf

That says it's cheaper to initialize a memory location (or a register) to zero
than to any other value. The code here, both before and after your change,
initializes CFG to whatever apr_hash_get() returns, so that doesn't apply.
(There is no intermediate initialization to zero in this case, either.)
Received on 2013-05-20 19:00:58 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.