aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTing-Wei Lan <tingwei.lan@cobinhood.com>2019-03-11 12:18:57 +0800
committerJhih-Ming Huang <jm.huang@cobinhood.com>2019-04-11 10:39:59 +0800
commitb4c31c4c714c557d6ecbf8004ffff44c5853b8cc (patch)
tree29445b36dcf04350256cfc490690e50039cf5b64
parent4fcdc62f4d202a5b599b999ec7dd9022d9d93eaa (diff)
downloaddexon-b4c31c4c714c557d6ecbf8004ffff44c5853b8cc.tar
dexon-b4c31c4c714c557d6ecbf8004ffff44c5853b8cc.tar.gz
dexon-b4c31c4c714c557d6ecbf8004ffff44c5853b8cc.tar.bz2
dexon-b4c31c4c714c557d6ecbf8004ffff44c5853b8cc.tar.lz
dexon-b4c31c4c714c557d6ecbf8004ffff44c5853b8cc.tar.xz
dexon-b4c31c4c714c557d6ecbf8004ffff44c5853b8cc.tar.zst
dexon-b4c31c4c714c557d6ecbf8004ffff44c5853b8cc.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.
-rw-r--r--core/vm/sqlvm/schema/schema.go6
-rw-r--r--core/vm/sqlvm/schema/schema_test.go12
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)
}
}
}