Mercurial > jwe > octave
comparison liboctave/util/oct-sort.cc @ 21168:26f85aa072de
maint: Replace instances of goto in liboctave where convenient.
* CMatrix.cc (operator >>): Replace "goto done;" with "return is;".
* CNDArray.cc (operator >>): Replace "goto done;" with "return is;".
* lo-specfun.cc (gammainc (various)) : Rename return variable result to retval. Replace
"goto done;" with "return XXX ();" where XXX is a container such as Matrix,
NDArray, FloatMatrix, FloatNDArray.
* lo-specfun.cc (gammainc (double, double, err), gammainc (float,float, err)):
Move input validation to top of function.
* randpoisson.c (poisson_cdf_lookup): Place action of if statement on separate line.
* cmd-edit.cc (do_decode_prompt_string): Replace goto statement with break.
Rename variable result to retval. Rename variable temp to tmpstr. Place
cases of switch statement in mostly alphabetical order. Use single quotes when
describing a single character. Use temporary number buffer of 32, not 128.
* oct-sort.cc (sort): Replace "goto fail;" with "return;"
author | Rik <rik@octave.org> |
---|---|
date | Mon, 01 Feb 2016 13:29:21 -0800 |
parents | 538b57866b90 |
children | f7121e111991 |
comparison
equal
deleted
inserted
replaced
21167:7705a858262b | 21168:26f85aa072de |
---|---|
1413 octave_idx_type n; | 1413 octave_idx_type n; |
1414 | 1414 |
1415 /* Identify next run. */ | 1415 /* Identify next run. */ |
1416 n = count_run (data + lo, nremaining, descending, comp); | 1416 n = count_run (data + lo, nremaining, descending, comp); |
1417 if (n < 0) | 1417 if (n < 0) |
1418 goto fail; | 1418 return; |
1419 if (descending) | 1419 if (descending) |
1420 std::reverse (data + lo, data + lo + n); | 1420 std::reverse (data + lo, data + lo + n); |
1421 /* If short, extend to min (minrun, nremaining). */ | 1421 /* If short, extend to min (minrun, nremaining). */ |
1422 if (n < minrun) | 1422 if (n < minrun) |
1423 { | 1423 { |
1430 assert (ms->n < MAX_MERGE_PENDING); | 1430 assert (ms->n < MAX_MERGE_PENDING); |
1431 ms->pending[ms->n].base = lo; | 1431 ms->pending[ms->n].base = lo; |
1432 ms->pending[ms->n].len = n; | 1432 ms->pending[ms->n].len = n; |
1433 ms->n++; | 1433 ms->n++; |
1434 if (merge_collapse (data, comp) < 0) | 1434 if (merge_collapse (data, comp) < 0) |
1435 goto fail; | 1435 return; |
1436 /* Advance to find next run. */ | 1436 /* Advance to find next run. */ |
1437 lo += n; | 1437 lo += n; |
1438 nremaining -= n; | 1438 nremaining -= n; |
1439 } | 1439 } |
1440 while (nremaining); | 1440 while (nremaining); |
1441 | 1441 |
1442 merge_force_collapse (data, comp); | 1442 merge_force_collapse (data, comp); |
1443 } | 1443 } |
1444 | |
1445 fail: | |
1446 return; | |
1447 } | 1444 } |
1448 | 1445 |
1449 template <typename T> | 1446 template <typename T> |
1450 template <typename Comp> | 1447 template <typename Comp> |
1451 void | 1448 void |
1473 octave_idx_type n; | 1470 octave_idx_type n; |
1474 | 1471 |
1475 /* Identify next run. */ | 1472 /* Identify next run. */ |
1476 n = count_run (data + lo, nremaining, descending, comp); | 1473 n = count_run (data + lo, nremaining, descending, comp); |
1477 if (n < 0) | 1474 if (n < 0) |
1478 goto fail; | 1475 return; |
1479 if (descending) | 1476 if (descending) |
1480 { | 1477 { |
1481 std::reverse (data + lo, data + lo + n); | 1478 std::reverse (data + lo, data + lo + n); |
1482 std::reverse (idx + lo, idx + lo + n); | 1479 std::reverse (idx + lo, idx + lo + n); |
1483 } | 1480 } |
1493 assert (ms->n < MAX_MERGE_PENDING); | 1490 assert (ms->n < MAX_MERGE_PENDING); |
1494 ms->pending[ms->n].base = lo; | 1491 ms->pending[ms->n].base = lo; |
1495 ms->pending[ms->n].len = n; | 1492 ms->pending[ms->n].len = n; |
1496 ms->n++; | 1493 ms->n++; |
1497 if (merge_collapse (data, idx, comp) < 0) | 1494 if (merge_collapse (data, idx, comp) < 0) |
1498 goto fail; | 1495 return; |
1499 /* Advance to find next run. */ | 1496 /* Advance to find next run. */ |
1500 lo += n; | 1497 lo += n; |
1501 nremaining -= n; | 1498 nremaining -= n; |
1502 } | 1499 } |
1503 while (nremaining); | 1500 while (nremaining); |
1504 | 1501 |
1505 merge_force_collapse (data, idx, comp); | 1502 merge_force_collapse (data, idx, comp); |
1506 } | 1503 } |
1507 | |
1508 fail: | |
1509 return; | |
1510 } | 1504 } |
1511 | 1505 |
1512 template <typename T> | 1506 template <typename T> |
1513 void | 1507 void |
1514 octave_sort<T>::sort (T *data, octave_idx_type nel) | 1508 octave_sort<T>::sort (T *data, octave_idx_type nel) |