Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pre-compile and store regexp in a hidden variable
as suggested by @PVince81 in Review #27257 (comment)
  • Loading branch information
individual-it authored Feb 27, 2017
commit d6dd36b1981fc539da107bca7b2a9aff16486b5f
8 changes: 7 additions & 1 deletion core/js/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -1734,6 +1734,12 @@ function relative_modified_date(timestamp) {
OC.Util = {
// TODO: remove original functions from global namespace
humanFileSize: humanFileSize,

/**
* regular expression to parse size in bytes from a humanly readable string
* see computerFileSize(string)
*/
_computerFileSizeRegexp: /^[\s+]?([0-9]*)(\.([0-9]+))?( +)?([kmgtp]?b?)$/i,

/**
* Returns a file size in bytes from a humanly readable string
Expand Down Expand Up @@ -1766,7 +1772,7 @@ OC.Util = {
'p': 1024 * 1024 * 1024 * 1024 * 1024
};

var matches = s.match(/^[\s+]?([0-9]*)(\.([0-9]+))?( +)?([kmgtp]?b?)$/i);
var matches = s.match(this._computerFileSizeRegexp);
if (matches !== null) {
bytes = parseFloat(s);
if (!isFinite(bytes)) {
Expand Down