diff options
author | Ting-Wei Lan <tingwei.lan@cobinhood.com> | 2019-03-11 12:18:57 +0800 |
---|---|---|
committer | Jhih-Ming Huang <jm.huang@cobinhood.com> | 2019-05-06 10:44:04 +0800 |
commit | 2c61a14511bb9d2f85b7c6621f5a177fdd241fc0 (patch) | |
tree | bf8f1aa56a145505c604e27ad3073bf8612aa98c /core/vm | |
parent | dae0bed2e0245020b6a8288adcf8cdb41bcbe45a (diff) | |
download | dexon-2c61a14511bb9d2f85b7c6621f5a177fdd241fc0.tar dexon-2c61a14511bb9d2f85b7c6621f5a177fdd241fc0.tar.gz dexon-2c61a14511bb9d2f85b7c6621f5a177fdd241fc0.tar.bz2 dexon-2c61a14511bb9d2f85b7c6621f5a177fdd241fc0.tar.lz dexon-2c61a14511bb9d2f85b7c6621f5a177fdd241fc0.tar.xz dexon-2c61a14511bb9d2f85b7c6621f5a177fdd241fc0.tar.zst dexon-2c61a14511bb9d2f85b7c6621f5a177fdd241fc0.zip |
core: vm: sqlvm: schema: drop pointers from slices
The number of tables, columns, indices are all limited to 256, so we
don't have to do much memory copying during appending. Drop pointers
from slices to save memory for storing pointers and possibly improve
locality.
Diffstat (limited to 'core/vm')
-rw-r--r-- | core/vm/sqlvm/schema/schema.go | 6 | ||||
-rw-r--r-- | core/vm/sqlvm/schema/schema_test.go | 12 |
2 files changed, 9 insertions, 9 deletions
diff --git a/core/vm/sqlvm/schema/schema.go b/core/vm/sqlvm/schema/schema.go index 76c843387..993843105 100644 --- a/core/vm/sqlvm/schema/schema.go +++ b/core/vm/sqlvm/schema/schema.go @@ -48,13 +48,13 @@ const ( ) // Schema defines sqlvm schema struct. -type Schema []*Table +type Schema []Table // Table defiens sqlvm table struct. type Table struct { Name []byte - Columns []*Column - Indices []*Index + Columns []Column + Indices []Index } // Index defines sqlvm index struct. diff --git a/core/vm/sqlvm/schema/schema_test.go b/core/vm/sqlvm/schema/schema_test.go index 5d252ef85..8a9044857 100644 --- a/core/vm/sqlvm/schema/schema_test.go +++ b/core/vm/sqlvm/schema/schema_test.go @@ -65,9 +65,9 @@ func (s *SchemaTestSuite) TestEncodeAndDecodeColumn() { func (s *SchemaTestSuite) TestEncodeAndDecodeSchema() { schema := Schema{ - &Table{ + Table{ Name: []byte("test"), - Columns: []*Column{ + Columns: []Column{ { column: column{ Name: []byte("a"), @@ -78,7 +78,7 @@ func (s *SchemaTestSuite) TestEncodeAndDecodeSchema() { Default: true, }, }, - Indices: []*Index{ + Indices: []Index{ { Name: []byte("idx"), Attr: IndexAttrUnique, @@ -86,7 +86,7 @@ func (s *SchemaTestSuite) TestEncodeAndDecodeSchema() { }, }, }, - &Table{ + Table{ Name: []byte("test2"), }, } @@ -111,13 +111,13 @@ func (s *SchemaTestSuite) TestEncodeAndDecodeSchema() { for j := 0; j < len(table.Columns); j++ { column := table.Columns[j] column2 := table.Columns[j] - s.Require().Equal(*column, *column2) + s.Require().Equal(column, column2) } for j := 0; j < len(table.Indices); j++ { index := table.Indices[j] index2 := table2.Indices[j] - s.Require().Equal(*index, *index2) + s.Require().Equal(index, index2) } } } |