From e490c8d3f328ce0b3fe37adaf87ddbc159981eec Mon Sep 17 00:00:00 2001 From: Braden Anderson Date: Sat, 13 Dec 2014 14:20:29 -0700 Subject: [PATCH] use fast mode automatically when safe --- papaparse.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/papaparse.js b/papaparse.js index 6531394..b216ebb 100644 --- a/papaparse.js +++ b/papaparse.js @@ -1012,24 +1012,29 @@ if (!input) return returnable(); - if (fastMode) + if (fastMode || input.indexOf('"') === -1) { - // Fast mode assumes there are no quoted fields in the input var rows = input.split(newline); for (var i = 0; i < rows.length; i++) { - if (comments && rows[i].substr(0, commentsLen) == comments) + var row = rows[i]; + cursor += row.length; + if (i !== rows.length - 1) + cursor += newline.length; + else if (ignoreLastRow) + return returnable(); + if (comments && row.substr(0, commentsLen) == comments) continue; if (stepIsFunction) { data = []; - pushRow(rows[i].split(delim)); + pushRow(row.split(delim)); doStep(); if (aborted) return returnable(); } else - pushRow(rows[i].split(delim)); + pushRow(row.split(delim)); if (preview && i >= preview) { data = data.slice(0, preview);