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

Re: [patch] Remove unused code in SVN::logReceiver()

From: Daniel Rall <dlr_at_collab.net>
Date: 2006-12-12 02:36:46 CET

Stefan wrote:

> Daniel Rall wrote:
> > [[[
> > Remove used code.
> ^^^^
>
> ??? :-)

Sorry! What is it with me and you and inverted negatives in my
emails? :-P

[[[
Remove unused code.

* src/SVN/SVN.cpp
  (SVN::logReceiver): Remove unnecessary "if" statement around log
   notification, and redundant "return error" statement.
]]]

...
> > Index: src/SVN/SVN.cpp
> > ===================================================================
> > --- src/SVN/SVN.cpp (revision 8244)
> > +++ src/SVN/SVN.cpp (working copy)
> > @@ -1214,10 +1214,7 @@
> > SVN_ERR (svn->cancel(baton));
> > #pragma warning(pop)
> >
> > - if (svn->Log(rev, author_native, date_native, msg_native, arChangedPaths, time_temp, filechanges, copies, actions))
> > - {
> > - return error;
> > - }
> > + svn->Log(rev, author_native, date_native, msg_native, arChangedPaths, time_temp, filechanges, copies, actions);
> > return error;
>
> We can't remove that code: the Log() method is virtual, and other
> classes have to override it to actually get the log data. Sure, right
> now no other class/dialog returns an error, but I like to have the
> option to maybe do that later (e.g. out-of-memory errors, other errors
> which might occur while trying to use the log data, ...)

Hmm, I'm not following. The SVN::Log() API returns a BOOL. The
"error" variable you see above is local to the SVN::logReceiver()
method. Regardless of whether SVN::Log() returns true or false, we
always return "error". Because of this, the "if" block which inspects
the return value of SVN::logReceiver() is unnecessary.

Here's two condensed forms of the method for comparison:

logReceiver()
{
  svn_error_t *error = NULL;
  ...
  if (svn->Log(...))
  {
    return error;
  }
  return error;
}

logReceiver()
{
  svn_error_t *error = NULL;
  ...
  svn->Log(...);
  return error;
}

Both forms to the same thing (call Log() and return "error"), but the
second form does it more clearly and concisely.

- Dan

  • application/pgp-signature attachment: stored
Received on Tue Dec 12 02:38:10 2006

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

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