Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor meaningless changes. #34

Merged
merged 3 commits into from
Feb 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions bql/grammar/llk.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,11 @@ func NewLLk(input string, k int) *LLk {
// appendNextToken tries to append a new token. If not tokens are available
// it appends ItemEOF token.
func appendNextToken(l *LLk) {
i := 0
for t := range l.c {
l.tkns = append(l.tkns, t)
i++
break
}
for ; i < 1; i++ {
l.tkns = append(l.tkns, lexer.Token{
Type: lexer.ItemEOF,
})
return
}
l.tkns = append(l.tkns, lexer.Token{Type: lexer.ItemEOF})
}

// Current returns the current token being processed.
Expand Down
27 changes: 10 additions & 17 deletions bql/table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (t *Table) Rows() []Row {
// AddBindings add the new binings provided to the table.
func (t *Table) AddBindings(bs []string) {
for _, b := range bs {
if _, ok := t.mbs[b]; !ok {
if !t.mbs[b] {
t.mbs[b] = true
t.bs = append(t.bs, b)
}
Expand Down Expand Up @@ -216,7 +216,7 @@ func equalBindings(b1, b2 map[string]bool) bool {
return false
}
for k := range b1 {
if _, ok := b2[k]; !ok {
if !b2[k] {
return false
}
}
Expand All @@ -242,22 +242,15 @@ func (t *Table) AppendTable(t2 *Table) error {
// disjointBinding returns true if they are not overlapping bindings, false
// otherwise.
func disjointBinding(b1, b2 map[string]bool) bool {
m := make(map[string]int)
for k := range b1 {
m[k]++
}
for k := range b2 {
m[k]++
}
for _, cnt := range m {
if cnt != 1 {
if b2[k] {
return false
}
}
return true
}

// MergeRows takes a list of rors and returns a new map containing both.
// MergeRows takes a list of rows and returns a new map containing both.
func MergeRows(ms []Row) Row {
res := make(map[string]*Cell)
for _, om := range ms {
Expand Down Expand Up @@ -750,13 +743,13 @@ func (t *Table) Reduce(cfg SortConfig, aaps []AliasAccPair) error {
return nil
}

// Filter removes all the rows were the provided function returns true.
// Filter removes all the rows where the provided function returns true.
func (t *Table) Filter(f func(Row) bool) {
for idx, processed := 0, len(t.data); processed > 0; processed-- {
if f(t.data[idx]) {
t.data = append(t.data[:idx], t.data[idx+1:]...)
idx--
var newData []Row
for _, r := range t.data {
if !f(r) {
newData = append(newData, r)
}
idx++
}
t.data = newData
}