mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
Use Ref for storing ast nodes in collections. (#37)
cmp, eq is done as pointer comparison which makes retrieval super fast. Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
d3fd0a3a78
commit
a751cd69e1
@@ -56,7 +56,13 @@ fn analyze_file(regos: &[String], expected_scopes: &[Scope]) -> Result<()> {
|
||||
|
||||
let analyzer = Analyzer::new();
|
||||
let schedule = analyzer.analyze(&modules_ref)?;
|
||||
for (idx, (_, scope)) in schedule.scopes.iter().enumerate() {
|
||||
let mut scopes: Vec<(&Query, ®orus::Scope)> = schedule
|
||||
.scopes
|
||||
.iter()
|
||||
.map(|(r, s)| (r.inner(), s))
|
||||
.collect();
|
||||
scopes.sort_by(|a, b| a.0.span.line.cmp(&b.0.span.line));
|
||||
for (idx, (_, scope)) in scopes.iter().enumerate() {
|
||||
if idx > expected_scopes.len() {
|
||||
bail!("extra scope generated.")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user