Commit ece67bc
committed
Use macro for wrapping += and -=
The current auto-generated += and -= implementation is hard to read, and should be replaced with += where possible. That said, we cannot auto-replace it just yet because Rust behaves differently in debug mode, therefore we should use second best approach - a macro that clearly shows intention without all the boilerplate code.
The only manual code are two macros in the src/enc/mod.rs
Use this replacement file as described in other recent PRs to replace boilerplate code.
<details>
<summary>replacement file content</summary>
```diff
@@
expression cond, expr;
@@
if cond
{
- let _rhs = 1;
- let _lhs = &mut expr;
- *_lhs = (*_lhs).wrapping_add(_rhs as u32);
+::wrapping_add!(expr, 1);
}
@@
expression expr;
@@
-{
- let _rhs = 1;
- let _lhs = &mut expr;
- *_lhs = (*_lhs).wrapping_add(_rhs as u32);
+::wrapping_add!(expr, 1);
-}
@@
expression expr;
@@
-{
- let _rhs = 1u32;
- let _lhs = &mut expr;
- *_lhs = (*_lhs).wrapping_add(_rhs);
+::wrapping_add!(expr, 1);
-}
@@
expression expr;
@@
-{
- let _rhs = 1i32;
- let _lhs = &mut expr;
- *_lhs = (*_lhs).wrapping_add(_rhs as u32);
+::wrapping_add!(expr, 1);
-}
@@
expression expr;
@@
-{
- let _rhs = 1;
- let _lhs = &mut expr;
- *_lhs = (*_lhs).wrapping_add(_rhs as usize);
+::wrapping_add!(expr, 1);
-}
@@
expression inc, expr;
@@
-{
- let _rhs = inc;
- let _lhs = &mut expr;
- *_lhs = (*_lhs).wrapping_add(_rhs as u32);
+::wrapping_add!(expr, inc as u32);
-}
@@
expression inc, expr;
@@
-{
- let _rhs = inc;
- let _lhs = &mut expr;
- *_lhs = (*_lhs).wrapping_add(_rhs);
+::wrapping_add!(expr, inc);
-}
@@
expression inc, expr;
@@
-{
- let _rhs = inc;
- let _lhs = &mut expr;
- *_lhs = (*_lhs).wrapping_add(_rhs as u32);
+::wrapping_add!(expr, inc as u32);
-}
@@
expression inc, expr;
@@
-{
- let _rhs = inc;
- let _lhs = &mut expr;
- *_lhs = (*_lhs).wrapping_add(_rhs as usize);
+::wrapping_add!(expr, inc as usize);
-}
@@
expression expr;
@@
-{
- let _rhs = 1;
- let _lhs = &mut expr;
- *_lhs = (*_lhs).wrapping_sub(_rhs as usize);
+::wrapping_sub!(expr, 1);
-}
```
</details>1 parent b9a4857 commit ece67bc
File tree
10 files changed
+103
-281
lines changed- src/enc
- backward_references
10 files changed
+103
-281
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1244 | 1244 | | |
1245 | 1245 | | |
1246 | 1246 | | |
1247 | | - | |
1248 | | - | |
1249 | | - | |
1250 | | - | |
1251 | | - | |
| 1247 | + | |
1252 | 1248 | | |
1253 | | - | |
1254 | | - | |
1255 | | - | |
| 1249 | + | |
1256 | 1250 | | |
1257 | 1251 | | |
1258 | 1252 | | |
1259 | | - | |
1260 | | - | |
1261 | | - | |
1262 | | - | |
1263 | | - | |
1264 | | - | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
1265 | 1258 | | |
1266 | 1259 | | |
1267 | 1260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
| 565 | + | |
570 | 566 | | |
571 | 567 | | |
572 | 568 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
923 | 923 | | |
924 | 924 | | |
925 | 925 | | |
926 | | - | |
927 | | - | |
928 | | - | |
929 | | - | |
930 | | - | |
| 926 | + | |
931 | 927 | | |
932 | 928 | | |
933 | 929 | | |
| |||
1665 | 1661 | | |
1666 | 1662 | | |
1667 | 1663 | | |
1668 | | - | |
1669 | | - | |
1670 | | - | |
1671 | | - | |
1672 | | - | |
1673 | | - | |
1674 | | - | |
1675 | | - | |
| 1664 | + | |
1676 | 1665 | | |
| 1666 | + | |
1677 | 1667 | | |
1678 | 1668 | | |
1679 | 1669 | | |
| |||
1969 | 1959 | | |
1970 | 1960 | | |
1971 | 1961 | | |
1972 | | - | |
1973 | | - | |
1974 | | - | |
1975 | | - | |
1976 | | - | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
1977 | 1966 | | |
1978 | 1967 | | |
1979 | 1968 | | |
| |||
2868 | 2857 | | |
2869 | 2858 | | |
2870 | 2859 | | |
2871 | | - | |
2872 | | - | |
2873 | | - | |
2874 | | - | |
2875 | | - | |
| 2860 | + | |
2876 | 2861 | | |
2877 | 2862 | | |
2878 | 2863 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
196 | 195 | | |
197 | 196 | | |
198 | 197 | | |
| |||
0 commit comments