public static void trim(Bytes bytes, Range target) { long start = target.start; long len = target.length; long finish = start + len - 1; if (start < 0 || len == 0) { return; } while (start < finish && bytes.get(start) == ' ') { start++; } while (start < finish && bytes.get(finish) == ' ') { finish--; } target.start = start; target.length = finish - start + 1; }