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-03-26 17:48:22 +0800
commitb0f778b53e7dfaf908b4c2e3f4e06399ab6701c3 (patch)
tree68ab8bc4eb97d533a55ef89c3fce6cad037b96db
parent50ab9d58e1f1820e78d328fdfdbf5a297ac4b1e6 (diff)
downloaddexon-b0f778b53e7dfaf908b4c2e3f4e06399ab6701c3.tar
dexon-b0f778b53e7dfaf908b4c2e3f4e06399ab6701c3.tar.gz
dexon-b0f778b53e7dfaf908b4c2e3f4e06399ab6701c3.tar.bz2
dexon-b0f778b53e7dfaf908b4c2e3f4e06399ab6701c3.tar.lz
dexon-b0f778b53e7dfaf908b4c2e3f4e06399ab6701c3.tar.xz
dexon-b0f778b53e7dfaf908b4c2e3f4e06399ab6701c3.tar.zst
dexon-b0f778b53e7dfaf908b4c2e3f4e06399ab6701c3.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)
}
}
}