replace max_len with if statements

Change-Id: I60d60e9b9ea0b7b6544a36bef7f4e263bb9de532
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/296416
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Zepeng Hu <zepenghu@google.com>
28 files changed