Skip to content

Commit 76fadc0

Browse files
authored
Merge pull request #529 from google/tidy
Cleanups, comments, debug logs.
2 parents 3dfedfe + ec4fa1f commit 76fadc0

8 files changed

Lines changed: 140 additions & 123 deletions

File tree

TODO

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,8 @@ Should the waker move into the tailer package?
121121
Benchmarks on GHA are too variable. Compute benchmarks old and new in same instance, per guidelines from "Software Microbenchmarking in the Cloud. How Bad is it Really?" Laaber et al.
122122

123123
Move loc and useCurrentYear out of VM and into Runtime env.
124+
125+
Move const folding into parser during AST build.
126+
Const-fold identity functions.
127+
128+
Replace IndexedExpr with no ExprList with just the IdTerm.

internal/exporter/prometheus.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func (e *Exporter) Collect(c chan<- prometheus.Metric) {
4646
go m.EmitLabelSets(lsc)
4747
for ls := range lsc {
4848
if lastMetric != m.Name {
49+
glog.V(2).Infof("setting source to %s", m.Source)
4950
lastSource = m.Source
5051
lastMetric = m.Name
5152
}

internal/metrics/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ func (s *Store) Add(m *Metric) error {
4747
// - copy old LabelValues into new metric;
4848
// - discard old metric.
4949
for i, v := range s.Metrics[m.Name] {
50-
//
5150
if v.Program != m.Program {
5251
continue
5352
}
@@ -87,6 +86,7 @@ func (s *Store) Add(m *Metric) error {
8786
s.searchMu.Lock()
8887
s.Metrics[m.Name] = append(s.Metrics[m.Name], m)
8988
if dupeIndex >= 0 {
89+
glog.V(2).Infof("removing original, keeping its clone")
9090
s.Metrics[m.Name] = append(s.Metrics[m.Name][0:dupeIndex], s.Metrics[m.Name][dupeIndex+1:]...)
9191
}
9292
s.searchMu.Unlock()

internal/runtime/compiler/checker/checker.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func (c *checker) checkSymbolUsage() {
250250
// Don't warn about the zeroth capture group; it's not user-defined.
251251
continue
252252
}
253-
glog.Infof("declaration of capture group reference `%s' at %s appears to be unused", sym.Name, sym.Pos)
253+
glog.Infof("capture group reference `%s' at %s appears to be unused", sym.Name, sym.Pos)
254254
continue
255255
}
256256
c.errors.Add(sym.Pos, fmt.Sprintf("Declaration of %s `%s' here is never used.", sym.Kind, sym.Name))
@@ -638,6 +638,14 @@ func (c *checker) VisitAfter(node ast.Node) ast.Node {
638638
n.SetType(types.Error)
639639
return n
640640
}
641+
642+
// Having typechecked the expression against the expected types, we
643+
// have detected mismatched keylengths, and can now fold to just IdTerm
644+
// if there's no ExprList.
645+
if len(exprList.Children) == 0 {
646+
return n.Lhs
647+
}
648+
641649
n.SetType(rType)
642650
return n
643651

internal/runtime/compiler/parser/parser.go

Lines changed: 42 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/runtime/compiler/parser/parser.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ primary_expr
441441
indexed_expr
442442
: id_expr
443443
{
444+
// Build an empty IndexedExpr so that the recursive rule below doesn't need to handle the alternative.
444445
$$ = &ast.IndexedExpr{Lhs: $1, Index: &ast.ExprList{}}
445446
}
446447
| indexed_expr LSQUARE arg_expr_list RSQUARE

0 commit comments

Comments
 (0)