vlang / v

Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io
MIT License
35.5k stars 2.15k forks source link

encoding.base32: fix warning of implicit clone of array by declaring unsafe #21728

Closed mike-ward closed 4 days ago

mike-ward commented 4 days ago

Received the following warning when importing encoding.base32

v run base32_test.v
/Users/mike/Documents/github/v/vlib/encoding/base32/base32.v:289:13: notice: an implicit clone of the slice was done here
  287 |             }
  288 |             in0 := src[0]
  289 |             src = src[1..]
      |                      ~~~~~
  290 |             if in0 == enc.padding_char && j >= 2 && src.len < 8 {
  291 |                 // We`ve reached the end and there`s padding
Details: /Users/mike/Documents/github/v/vlib/encoding/base32/base32.v:289:13: details: To silence this notice, use either an explicit `a[..].clone()`,
or use an explicit `unsafe{ a[..] }`, if you do not want a copy of the slice.
  287 |             }
  288 |             in0 := src[0]
  289 |             src = src[1..]
      |                      ~~~~~
  290 |             if in0 == enc.padding_char && j >= 2 && src.len < 8 {
  291 |                 // We`ve reached the end and there`s padding

This PR uses an explicit unsafe to suppress the warning.