[PyTorch] Fix missing move in torch::jit::Lexer::next (#64653)
authorScott Wolchok <swolchok@fb.com>
Fri, 10 Sep 2021 01:53:36 +0000 (18:53 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 10 Sep 2021 02:01:07 +0000 (19:01 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/64653

Saves shared_ptr refcount inc/dec in SourceRange.
ghstack-source-id: 137608457

Test Plan: Profiled startup of framework overheads benchmark from high_per_models; self time spent in next() is way down.

Reviewed By: dhruvbird

Differential Revision: D30739240

fbshipit-source-id: ac455678c9d46e657b111d3788d4369983028674

torch/csrc/jit/frontend/lexer.h

index c2bd32f..b151fc0 100644 (file)
@@ -402,7 +402,7 @@ struct Lexer {
   Token next() {
     if (next_tokens.size() == 0)
       reportError("Lexer invariant violated: empty token queue");
-    Token r = next_tokens.front();
+    Token r = std::move(next_tokens.front());
     next_tokens.erase(next_tokens.begin());
     if (next_tokens.size() == 0) {
       lex();