Skip to content

Commit 9fc5382

Browse files
committed
(improvement) readTypeInfo: fast-path for simple native types
Add early return for native type IDs (0x0001 through TypeDuration), skipping the TypeCustom check and the collection/UDT/tuple switch. Also convert single-case type switch to a type assertion. Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
1 parent 16bcc44 commit 9fc5382

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

frame.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,11 @@ func (f *framer) readTypeInfo() TypeInfo {
712712
typ: Type(id),
713713
}
714714

715+
// Fast path for simple native types (through TypeDuration).
716+
if id > 0 && id <= uint16(TypeDuration) {
717+
return simple
718+
}
719+
715720
if simple.typ == TypeCustom {
716721
simple.custom = f.readString()
717722
if cassType := getApacheCassandraType(simple.custom); cassType != TypeCustom {
@@ -923,11 +928,9 @@ func (f *framer) readColWithSpec(col *ColumnInfo, meta *resultMetadata, globalSp
923928

924929
col.Name = f.readString()
925930
col.TypeInfo = f.readTypeInfo()
926-
switch v := col.TypeInfo.(type) {
927-
// maybe also UDT
928-
case TupleTypeInfo:
931+
if tuple, ok := col.TypeInfo.(TupleTypeInfo); ok {
929932
// -1 because we already included the tuple column
930-
meta.actualColCount += len(v.Elems) - 1
933+
meta.actualColCount += len(tuple.Elems) - 1
931934
}
932935

933936
return col.Keyspace, col.Table

0 commit comments

Comments
 (0)