Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make fields/developerFields n buffer size 255 instead of 256 #303

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions cmd/fitconv/fitcsv/csv_to_fit.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/muktihari/fit/profile/typedef"
"github.com/muktihari/fit/profile/untyped/mesgnum"
"github.com/muktihari/fit/proto"
"golang.org/x/exp/slices"
)

type CSVToFITConv struct {
Expand All @@ -29,9 +30,9 @@ type CSVToFITConv struct {

fit proto.FIT

fieldsArray [256]proto.Field
developerFieldsArray [256]proto.DeveloperField
protoValuesArray [256]proto.Value
fieldsArray [255]proto.Field
developerFieldsArray [255]proto.DeveloperField
protoValuesArray [255]proto.Value

fieldDescriptions []*mesgdef.FieldDescription

Expand Down Expand Up @@ -134,10 +135,8 @@ loop:
}

if c.streamEnc == nil {
mesg.Fields = make([]proto.Field, len(mesg.Fields))
copy(mesg.Fields, c.fieldsArray[:])
mesg.DeveloperFields = make([]proto.DeveloperField, len(mesg.DeveloperFields))
copy(mesg.DeveloperFields, c.developerFieldsArray[:])
mesg.Fields = slices.Clone(mesg.Fields)
mesg.DeveloperFields = slices.Clone(mesg.DeveloperFields)
c.fit.Messages = append(c.fit.Messages, mesg)
continue loop
}
Expand Down
4 changes: 2 additions & 2 deletions decoder/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ type Decoder struct {
accumulator *Accumulator
crc16 hash.Hash16

fieldsArray [256]proto.Field
developersFieldsArray [256]proto.DeveloperField
fieldsArray [255]proto.Field
developersFieldsArray [255]proto.DeveloperField

options options

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/fitgen/profile/mesgdef/mesgdef.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (m *{{ .Name }}) ToMesg(options *Options) proto.Message {

fac := options.Factory

arr := pool.Get().(*[256]proto.Field)
arr := pool.Get().(*[255]proto.Field)
defer pool.Put(arr)

fields := arr[:0] // Create slice from array with zero len.
Expand Down
2 changes: 1 addition & 1 deletion profile/mesgdef/aad_accel_features_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/accelerometer_data_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/activity_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/ant_channel_id_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/ant_rx_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/ant_tx_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/aviation_attitude_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/barometer_data_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/beat_intervals_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/bike_profile_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/blood_pressure_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/cadence_zone_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/camera_event_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/capabilities_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/chrono_shot_data_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/chrono_shot_session_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/climb_pro_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/connectivity_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/course_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/course_point_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/developer_data_id_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/device_aux_battery_info_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/device_info_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/device_settings_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/dive_alarm_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/dive_apnea_alarm_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/dive_gas_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/dive_settings_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/dive_summary_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/event_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/exd_data_concept_configuration_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/exd_data_field_configuration_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/exd_screen_configuration_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/exercise_title_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/field_capabilities_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/field_description_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/file_capabilities_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion profile/mesgdef/file_creator_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading