test-likeliness.smpl 600 B

12345678910111213141516171819202122232425262728
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. // Copyright © 2018-2019 Ariadne Devos
  3. // sHT -- replace some superfluous likely/unlikely
  4. @ double_unlikely @
  5. @@
  6. - sHT_unlikely(
  7. \(sHT_gt\|sHT_ge\|sHT_eq\|sHT_lt0\|sHT_zero_p\|sHT_nonzero_p\|sHT_eq_pointer\|sHT_null_p\)(...)
  8. - )
  9. @ double_likely @
  10. @@
  11. - sHT_likely(
  12. !\(sHT_gt\|sHT_ge\|sHT_eq\|sHT_lt0\|sHT_zero_p\|sHT_nonzero_p\|sHT_eq_pointer\|sHT_null_p\)(...)
  13. - )
  14. @ correct_likely_zero @
  15. expression e;
  16. @@
  17. - sHT_likely(sHT_zero_p(e))
  18. + !sHT_nonzero_p(e)
  19. @ correct_likely_nonzero @
  20. expression e;
  21. @@
  22. - sHT_likely(sHT_nonzero_p(e))
  23. + !sHT_zero_p(e)