Skip to content

Commit 27eaac8

Browse files
committed
manifest: refactor {Smallest, Largest}Bound
This commit refactors the `SmallestBound`/`LargestBound` methods so that future commits will not allocate unnecessarily. Informs: #2047
1 parent a2f076b commit 27eaac8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

internal/manifest/version.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -724,15 +724,15 @@ func (m *TableMetadata) ContainsKeyType(kt KeyType) bool {
724724
// SmallestBound returns the file's smallest bound of the key type. It returns a
725725
// false second return value if the file does not contain any keys of the key
726726
// type.
727-
func (m *TableMetadata) SmallestBound(kt KeyType) (*InternalKey, bool) {
727+
func (m *TableMetadata) SmallestBound(kt KeyType) (InternalKey, bool) {
728728
switch kt {
729729
case KeyTypePointAndRange:
730730
ik := m.Smallest()
731-
return &ik, true
731+
return ik, true
732732
case KeyTypePoint:
733-
return &m.SmallestPointKey, m.HasPointKeys
733+
return m.SmallestPointKey, m.HasPointKeys
734734
case KeyTypeRange:
735-
return &m.SmallestRangeKey, m.HasRangeKeys
735+
return m.SmallestRangeKey, m.HasRangeKeys
736736
default:
737737
panic("unrecognized key type")
738738
}
@@ -741,15 +741,15 @@ func (m *TableMetadata) SmallestBound(kt KeyType) (*InternalKey, bool) {
741741
// LargestBound returns the file's largest bound of the key type. It returns a
742742
// false second return value if the file does not contain any keys of the key
743743
// type.
744-
func (m *TableMetadata) LargestBound(kt KeyType) (*InternalKey, bool) {
744+
func (m *TableMetadata) LargestBound(kt KeyType) (InternalKey, bool) {
745745
switch kt {
746746
case KeyTypePointAndRange:
747747
ik := m.Largest()
748-
return &ik, true
748+
return ik, true
749749
case KeyTypePoint:
750-
return &m.LargestPointKey, m.HasPointKeys
750+
return m.LargestPointKey, m.HasPointKeys
751751
case KeyTypeRange:
752-
return &m.LargestRangeKey, m.HasRangeKeys
752+
return m.LargestRangeKey, m.HasRangeKeys
753753
default:
754754
panic("unrecognized key type")
755755
}

0 commit comments

Comments
 (0)