Would be better to move the assignments and logic below the declarations. In particular the dependence of `prefix_len` on `has_prefix` is a bit hidden up here.