entriesToDoubles static method

List<double> entriesToDoubles(
  1. List<Float32x4> list
)

Implementation

static List<double> entriesToDoubles(List<Float32x4> list) {
  final lastEntryIndex = list.length - 1;
  var entryIndex = 0;
  var entry = list.first;
  var entryCursor = -1;
  var valueCursor = -1;

  var fs = List.generate(list.length * 4, (i) {
    assert(++valueCursor == i);

    switch (++entryCursor) {
      case 0:
        {
          return entry.x;
        }
      case 1:
        {
          return entry.y;
        }
      case 2:
        {
          return entry.z;
        }
      case 3:
        {
          var w = entry.w;
          if (entryIndex < lastEntryIndex) {
            entry = list[++entryIndex];
            entryCursor = -1;
          }
          return w;
        }
      default:
        throw StateError('Invalid entryCursor: $entryCursor');
    }
  });

  return fs;
}