Skip to content

Commit

Permalink
perf: add fast path to get log class type for most common types
Browse files Browse the repository at this point in the history
 'METHOD_ENTRY' => MethodEntryLine;
 'METHOD_EXIT' => MethodExitLine;
 'CONSTRUCTOR_ENTRY' => ConstructorEntryLine;
 'CONSTRUCTOR_EXIT' => ConstructorExitLine;
  • Loading branch information
lukecotter committed Jan 4, 2024
1 parent 29f4b88 commit fedfd9e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions log-viewer/modules/parsers/ApexLogParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2434,6 +2434,29 @@ class MatchEngineBegin extends Method {
}

function getLogEventClass(eventName: LogEventType): LogLineConstructor | null | undefined {
// Fast path for the most commonly occuring types
switch (eventName) {
case 'METHOD_ENTRY':
return MethodEntryLine;
break;

case 'METHOD_EXIT':
return MethodExitLine;
break;

case 'CONSTRUCTOR_ENTRY':
return ConstructorEntryLine;
break;

case 'CONSTRUCTOR_EXIT':
return ConstructorExitLine;
break;

default:
break;
}

// Handle all other types
const logType = lineTypeMap.get(eventName);
if (logType) {
return logType;
Expand Down

0 comments on commit fedfd9e

Please sign in to comment.