Skip to content

Commit

Permalink
pkg/slayers: remove unnecessary sub-slicing.
Browse files Browse the repository at this point in the history
  • Loading branch information
jiceatscion committed Jul 16, 2024
1 parent eab1cab commit 4d294f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/slayers/path/scion/decoded.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (s *Decoded) SerializeTo(b []byte) error {
return serrors.New("buffer too small to serialize path.", "expected", s.Len(),
"actual", len(b))
}
if err := s.PathMeta.SerializeTo(b[:MetaLen]); err != nil {
if err := s.PathMeta.SerializeTo(b); err != nil {
return err
}
offset := MetaLen
Expand Down
8 changes: 4 additions & 4 deletions pkg/slayers/path/scion/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func (s *Raw) SerializeTo(b []byte) error {
return serrors.New("buffer too small", "expected", minLen, "actual", len(b))
}
// XXX(roosd): This modifies the underlying buffer. Consider writing to data
// directly.
if err := s.PathMeta.SerializeTo(s.Raw[:MetaLen]); err != nil {
// directly. XXX(jiceatscion): Do we not want to update s.Raw anyway?
if err := s.PathMeta.SerializeTo(s.Raw); err != nil {
return err
}
copy(b, s.Raw)
Expand Down Expand Up @@ -82,7 +82,7 @@ func (s *Raw) Reverse() (path.Path, error) {
// ToDecoded transforms a scion.Raw to a scion.Decoded.
func (s *Raw) ToDecoded() (*Decoded, error) {
// Serialize PathMeta to ensure potential changes are reflected Raw.
if err := s.PathMeta.SerializeTo(s.Raw[:MetaLen]); err != nil {
if err := s.PathMeta.SerializeTo(s.Raw); err != nil {
return nil, err
}
decoded := &Decoded{}
Expand All @@ -97,7 +97,7 @@ func (s *Raw) IncPath() error {
if err := s.Base.IncPath(); err != nil {
return err
}
return s.PathMeta.SerializeTo(s.Raw[:MetaLen])
return s.PathMeta.SerializeTo(s.Raw)
}

// GetInfoField returns the InfoField at a given index.
Expand Down

0 comments on commit 4d294f1

Please sign in to comment.