Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Instead of

    let surrogate_mask = surrogate_bit << 2 | surrogate_bit << 1 | surrogate_bit;
    len &= !surrogate_mask;
consider

    len &= surrogate_bit.wrapping_sub(1);
This should still work better. Alternatively, invert the conditions and do

    len &= non_surrogate_bit.wrapping_neg();


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: