From 4ea90ad084e9a8e56df88983e564757fecefbcbf Mon Sep 17 00:00:00 2001 From: Don Stewart Date: Mon, 12 Sep 2022 21:29:50 -0700 Subject: [PATCH] Share span lookup across both cxx defn xref results Summary: Slight optimization. We were computing the span twice, once for the decl -> def target, and against for the def -> decl target. Just do it once outside the loop. Reviewed By: nhawkes Differential Revision: D39414932 fbshipit-source-id: ea5047ed9b09cedded3c1bd17e59fac0b98e694b --- glean/schema/py/symbolidcxx.py | 1 + glean/schema/source/codemarkup.cxx.angle | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/glean/schema/py/symbolidcxx.py b/glean/schema/py/symbolidcxx.py index 3a2735a92..82a50b434 100644 --- a/glean/schema/py/symbolidcxx.py +++ b/glean/schema/py/symbolidcxx.py @@ -2,6 +2,7 @@ # To regenerate this file run fbcode//glean/schema/gen/sync from typing import Optional, Tuple, Union, List, Dict, TypeVar from thrift.py3 import Struct +from enum import Enum import ast from glean.schema.py.glean_schema_predicate import GleanSchemaPredicate, angle_for, R, Just, InnerGleanSchemaPredicate from glean.schema.py.cxx1 import * diff --git a/glean/schema/source/codemarkup.cxx.angle b/glean/schema/source/codemarkup.cxx.angle index b1fcd4421..f2ce00b60 100644 --- a/glean/schema/source/codemarkup.cxx.angle +++ b/glean/schema/source/codemarkup.cxx.angle @@ -207,12 +207,12 @@ predicate CxxFileEntityTraceDeclToDefXRefLocations: { File, Trace, XRef, Entity } where Trace = cxx1.Trace { File, cxx1.Declarations Decls, _ }; Decl = Decls[..]; + cxx1.DeclarationNameSpan { Decl, _, Span }; # Get xrefs from decl to defn ,and defn back to decl family ({ Entity, Location } where CxxDeclToDefXRefTargetLocation { Decl, Entity, Location } | CxxDefToDeclFamilyXRefTargetLocation { Decl, Entity, Location } ); - cxx1.DeclarationNameSpan { Decl, _, Span }; { Location, { span = Span }} = XRef; # For a given Decl, it might have a base Defn, build an entity for that