Given a (large) rectangular array, e.g. (small for example case):
Column[{test, test // MatrixForm}, Left, 2]
(*
{{1, 3, 0, 3, 0}, {1, 3, 0, 3, 3}, {0, 2, 3, 1, 3}, {2, 0, 0, 0, 0},
{2, 0, 2, 3, 1}, {0, 0, 0, 0, 0}, {0, 0, 1, 0, 0}}
*)

I need to remove any leading/trailing zeroes from rows, dropping row if all zeroes, e.g. with above the result s/b
(* {{1, 3, 0, 3}, {1, 3, 0, 3, 3}, {2, 3, 1, 3}, {2}, {2, 0, 2, 3, 1}, {1}} *)
I'm using
trim0 = With[{t = DeleteCases[#, ConstantArray[0, Length@#[[1]]]]},
MapIndexed[t[[First@#2, #1[[1]] ;; #1[[-1]]]] &, SparseArray[t]["AdjacencyLists"]]] &;
Might there be a faster method?
N.B.: Currently, I'm working with arrays of non-negative integers, so if that can be used to speed things (above is general)...
{10x10^6, 5}. This may cause a slow down, depending on the machine spec. I have worked out a solution that performs within a few percentage at the same speed for rows of size 5 and far less memory requirements. Depending on hardware, memory consumption of algorithm may have significant impact. I thought that's not worthwhile posting my answer (because only within a few percent of speed of your proposal), however if you wish than let me know and I can post it. – penguin77 Apr 19 '15 at 23:28