From 88c0ea91317b48a3f2fc07a0229f51977b3cc7e6 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Thu, 9 Sep 2021 18:53:36 -0700 Subject: [PATCH] [PyTorch] Fix missing move in torch::jit::Lexer::next (#64653) 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torch/csrc/jit/frontend/lexer.h b/torch/csrc/jit/frontend/lexer.h index c2bd32f..b151fc0 100644 --- a/torch/csrc/jit/frontend/lexer.h +++ b/torch/csrc/jit/frontend/lexer.h @@ -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(); -- 2.7.4