Reworks date parsing, formatting etc for perf

Isolates moment.js
This commit is contained in:
Eric Amodio
2017-09-14 21:33:04 -04:00
parent 11eacb27a1
commit aacf7cc2b5
18 changed files with 87 additions and 42 deletions

View File

@@ -1,7 +1,6 @@
'use strict';
import { Strings } from '../../system';
import { Git, GitAuthor, GitBlame, GitBlameCommit, GitCommitLine } from './../git';
import * as moment from 'moment';
import * as path from 'path';
interface BlameEntry {
@@ -134,7 +133,7 @@ export class GitBlameParser {
}
}
commit = new GitBlameCommit(repoPath!, entry.sha, fileName!, entry.author, moment(`${entry.authorDate} ${entry.authorTimeZone}`, 'X +-HHmm').toDate(), entry.summary!, []);
commit = new GitBlameCommit(repoPath!, entry.sha, fileName!, entry.author, new Date(entry.authorDate as any * 1000), entry.summary!, []);
if (fileName !== entry.fileName) {
commit.originalFileName = entry.fileName;

View File

@@ -3,7 +3,6 @@ import { Strings } from '../../system';
import { Range } from 'vscode';
import { Git, GitAuthor, GitCommitType, GitLog, GitLogCommit, GitStatusFileStatus, IGitStatusFile } from './../git';
// import { Logger } from '../../logger';
import * as moment from 'moment';
import * as path from 'path';
interface LogEntry {
@@ -87,7 +86,7 @@ export class GitLogParser {
break;
case 'author-date':
entry.authorDate = `${lineParts[1]}T${lineParts[2]}${lineParts[3]}`;
entry.authorDate = lineParts[1];
break;
case 'parents':
@@ -231,7 +230,7 @@ export class GitLogParser {
}
}
commit = new GitLogCommit(type, repoPath!, entry.sha, relativeFileName, entry.author, moment(entry.authorDate).toDate(), entry.summary!, entry.status, entry.fileStatuses, undefined, entry.originalFileName);
commit = new GitLogCommit(type, repoPath!, entry.sha, relativeFileName, entry.author, new Date(entry.authorDate! as any * 1000), entry.summary!, entry.status, entry.fileStatuses, undefined, entry.originalFileName);
commit.parentShas = entry.parentShas!;
if (relativeFileName !== entry.fileName) {

View File

@@ -1,7 +1,6 @@
'use strict';
import { Git, GitStash, GitStashCommit, GitStatusFileStatus, IGitStatusFile } from './../git';
// import { Logger } from '../../logger';
import * as moment from 'moment';
interface StashEntry {
sha: string;
@@ -42,7 +41,7 @@ export class GitStashParser {
switch (lineParts[0]) {
case 'author-date':
entry.date = `${lineParts[1]}T${lineParts[2]}${lineParts[3]}`;
entry.date = lineParts[1];
break;
case 'summary':
@@ -120,7 +119,7 @@ export class GitStashParser {
let commit = commits.get(entry.sha);
if (commit === undefined) {
commit = new GitStashCommit(entry.stashName, repoPath, entry.sha, entry.fileNames, moment(entry.date).toDate(), entry.summary, undefined, entry.fileStatuses) as GitStashCommit;
commit = new GitStashCommit(entry.stashName, repoPath, entry.sha, entry.fileNames, new Date(entry.date! as any * 1000), entry.summary, undefined, entry.fileStatuses) as GitStashCommit;
commits.set(entry.sha, commit);
}
}