octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

remove break in loops after error () ?


From: Andreas Weber
Subject: remove break in loops after error () ?
Date: Fri, 18 Dec 2015 21:16:48 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0

Dear maintainers,

after removing return after error () during the CodeSprint, shouldn't we
also remove breaks in loops and "success = false;" assignments after
error ()?

One example: octave-value/ov-fcn-handle.cc:1156

 if (num_obj != static_cast<hsize_t>(len))
    {
      error ("load: failed to load anonymous function handle");
      success = false;
    }

  hdf5_callback_data dsub;
  int current_item = 0;
  for (octave_idx_type i = 0; i < len; i++)
    {
      if (H5Giterate (group_hid, "symbol table", &current_item,
                      hdf5_read_next_data, &dsub) <= 0)
        {
          error ("load: failed to load anonymous function handle");
          success = false;
          break;
        }

      symbol_table::assign (dsub.name, dsub.tc, local_scope);
    }

Instead I would write

 if (num_obj != static_cast<hsize_t>(len))
  error ("load: failed to load anonymous function handle");

  hdf5_callback_data dsub;
  int current_item = 0;
  for (octave_idx_type i = 0; i < len; i++)
    {
      if (H5Giterate (group_hid, "symbol table", &current_item,
                      hdf5_read_next_data, &dsub) <= 0)
        error ("load: failed to load anonymous function handle");

      symbol_table::assign (dsub.name, dsub.tc, local_scope);
    }

-- Andy

PS: I used grep -RnA4 "error (" |grep break -B4|less
but I'm sure the perl experts would find a much better way to find these ;-)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]