Blender Git Loki

Git Commits -> Revision 6c2e1f3

Revision 6c2e1f3 by Jacques Lucke (master)
February 20, 2021, 21:05 (GMT)
BLI: cleanup StringRef and Span and improve parameter validation

Previously, methods like `Span.drop_front` would crash when more
elements would be dropped than are available. While this is most
efficient, it is not very practical in some use cases. Also other languages
silently clamp the index, so one can easily write wrong code accidentally.

Now, `Span.drop_front` and similar methods will only crash when n
is negative. Too large values will be clamped down to their maximum
possible value. While this is slightly less efficient, I did not have a case
where this actually mattered yet. If it does matter in the future, we can
add a separate `*_unchecked` method.

This should not change the behavior of existing code.

Commit Details:

Full Hash: 6c2e1f33983766ee5ee028e14a24e36c28d0a566
Parent Commit: d8b4246
Lines Changed: +119, -49

4 Modified Paths:

/source/blender/blenlib/BLI_span.hh (+47, -33) (Diff)
/source/blender/blenlib/BLI_string_ref.hh (+12, -12) (Diff)
/source/blender/blenlib/tests/BLI_span_test.cc (+41, -1) (Diff)
/source/blender/blenlib/tests/BLI_string_ref_test.cc (+19, -3) (Diff)
Tehnyt: Miika HämäläinenViimeksi päivitetty: 07.11.2014 14:18MiikaH:n Sivut a.k.a. MiikaHweb | 2003-2021