Skip to content

Commit

Permalink
Reduce by 3x number of calls to LexerLocation lookups in package seri…
Browse files Browse the repository at this point in the history
…alization.

--
MOS_MIGRATED_REVID=99279879
  • Loading branch information
ericfelly authored and lberki committed Jul 29, 2015
1 parent a189640 commit e4d8482
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,17 @@ private static Build.Location serializeLocation(Location location) {
Build.Location.Builder result = Build.Location.newBuilder();

result.setStartOffset(location.getStartOffset());
if (location.getStartLineAndColumn() != null) {
result.setStartLine(location.getStartLineAndColumn().getLine());
result.setStartColumn(location.getStartLineAndColumn().getColumn());
Location.LineAndColumn startLineAndColumn = location.getStartLineAndColumn();
if (startLineAndColumn != null) {
result.setStartLine(startLineAndColumn.getLine());
result.setStartColumn(startLineAndColumn.getColumn());
}

result.setEndOffset(location.getEndOffset());
if (location.getEndLineAndColumn() != null) {
result.setEndLine(location.getEndLineAndColumn().getLine());
result.setEndColumn(location.getEndLineAndColumn().getColumn());
Location.LineAndColumn endLineAndColumn = location.getEndLineAndColumn();
if (endLineAndColumn != null) {
result.setEndLine(endLineAndColumn.getLine());
result.setEndColumn(endLineAndColumn.getColumn());
}

return result.build();
Expand Down

0 comments on commit e4d8482

Please sign in to comment.