From d7409c6fd97c735583936a42a1510f9101157ade Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Fri, 3 Jan 2025 14:46:46 +0530 Subject: [PATCH] refactor: remove additional struct Signed-off-by: Harshit Gangal --- go/vt/vtgate/vindexes/vschema.go | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/go/vt/vtgate/vindexes/vschema.go b/go/vt/vtgate/vindexes/vschema.go index 5c0bfd274c1..522f826bb53 100644 --- a/go/vt/vtgate/vindexes/vschema.go +++ b/go/vt/vtgate/vindexes/vschema.go @@ -475,11 +475,7 @@ func buildGlobalTables(source *vschemapb.SrvVSchema, vschema *VSchema) { // AddAdditionalGlobalTables adds unique tables from unsharded keyspaces to the global tables. // It is expected to be called from the schema tracking code. func AddAdditionalGlobalTables(source *vschemapb.SrvVSchema, vschema *VSchema) { - type tableInfo struct { - table *Table - cnt int - } - newTables := make(map[string]*tableInfo) + newTables := make(map[string]*Table) // Collect valid uniquely named tables from unsharded keyspaces. for ksname, ks := range source.Keyspaces { @@ -494,21 +490,17 @@ func AddAdditionalGlobalTables(source *vschemapb.SrvVSchema, vschema *VSchema) { _, ok := newTables[tname] if !ok { table.Keyspace = ksvschema.Keyspace - newTables[tname] = &tableInfo{table: table, cnt: 0} + newTables[tname] = table + } else { + newTables[tname] = nil } - newTables[tname].cnt++ } } } // Mark new tables found just once as globally routable, rest as ambiguous. - for tname, ti := range newTables { - switch ti.cnt { - case 1: - vschema.globalTables[tname] = ti.table - default: - vschema.globalTables[tname] = nil - } + for k, v := range newTables { + vschema.globalTables[k] = v } }