# HG changeset patch # User Rik # Date 1664996632 25200 # Node ID b8f4ec18e728cd62199a175ff069757aefde79ce # Parent 5f7d5934a1a9739426bcfa175e8519edf0200cdb Allow cell input to cell() function (bug #63132) * ov-cell.cc (Fcell): Check if single input is already a cell and return it immediately if it is. diff -r 5f7d5934a1a9 -r b8f4ec18e728 libinterp/octave-value/ov-cell.cc --- a/libinterp/octave-value/ov-cell.cc Wed Oct 05 11:53:05 2022 -0700 +++ b/libinterp/octave-value/ov-cell.cc Wed Oct 05 12:03:52 2022 -0700 @@ -1261,7 +1261,10 @@ break; case 1: - get_dimensions (args(0), "cell", dims); + if (args(0).iscell ()) + return args(0); // shortcut path for input which is already a Cell + else + get_dimensions (args(0), "cell", dims); break; default: @@ -1283,6 +1286,15 @@ } /* + +%!test <*63132> +%! x = {1, 3}; +%! y = cell (x); +%! assert (x, y); +%! x = cell (0, 3); +%! y = cell (x); +%! assert (x, y); + ## This might work on some system someday, but for now, who has a system ## where a 16 yottabyte array can be allocated? See bug #50934. %!error cell (1e24, 1)