Skip to content

Commit

Permalink
tables: Rename a variable (pingcap#5673)
Browse files Browse the repository at this point in the history
  • Loading branch information
shenli authored and zz-jason committed Jan 18, 2018
1 parent 8069afd commit 45d916b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions table/tables/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@ type index struct {
idxInfo *model.IndexInfo
prefix kv.Key

// buffer is used reduce the number of new slice when multiple index keys are created.
// ddlReorgBuffer is used reduce the number of new slice when multiple index keys are created.
// It is not thread-safe, is only used in ddl index reorganization stage, please don't use it in other case.
buffer []byte
ddlReorgBuffer []byte
}

// NewIndexWithBuffer builds a new Index object whit the buffer.
func NewIndexWithBuffer(tableInfo *model.TableInfo, indexInfo *model.IndexInfo) table.Index {
idxPrefix := tablecodec.EncodeTableIndexPrefix(tableInfo.ID, indexInfo.ID)
index := &index{
tblInfo: tableInfo,
idxInfo: indexInfo,
prefix: idxPrefix,
buffer: make([]byte, 0, len(idxPrefix)+len(indexInfo.Columns)*9+9),
tblInfo: tableInfo,
idxInfo: indexInfo,
prefix: idxPrefix,
ddlReorgBuffer: make([]byte, 0, len(idxPrefix)+len(indexInfo.Columns)*9+9),
}
return index
}
Expand All @@ -137,8 +137,8 @@ func (c *index) getIndexKeyBuf(buf []byte, defaultCap int) []byte {
return buf[:0]
}

if c.buffer != nil {
return c.buffer[:0]
if c.ddlReorgBuffer != nil {
return c.ddlReorgBuffer[:0]
}

return make([]byte, 0, defaultCap)
Expand Down

0 comments on commit 45d916b

Please sign in to comment.