From f5ac906476cd26f2967a48340940e6af580fa71f Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Tue, 19 Jun 2018 12:55:53 -0400 Subject: [skottie] Simplify Parse Some BM versions wrap point values as single or even multi-element arrays. Parse already handles the former case - we can extend that behavior to also cover the latter and simplify Parse. TBR= Change-Id: I2152928944f43dc03a5d8f0d65865ac43974fd7a Reviewed-on: https://skia-review.googlesource.com/135800 Reviewed-by: Florin Malita Commit-Queue: Florin Malita --- modules/skottie/src/SkottieJson.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'modules') diff --git a/modules/skottie/src/SkottieJson.cpp b/modules/skottie/src/SkottieJson.cpp index 186cd42c31..23221af99e 100644 --- a/modules/skottie/src/SkottieJson.cpp +++ b/modules/skottie/src/SkottieJson.cpp @@ -24,7 +24,7 @@ template <> bool Parse(const Value& v, SkScalar* s) { // Some versions wrap values as single-element arrays. if (const skjson::ArrayValue* array = v) { - if (array->size() == 1) { + if (array->size() > 0) { return Parse((*array)[0], s); } } @@ -80,16 +80,8 @@ bool Parse(const Value& v, SkPoint* pt) { return false; const auto& ov = v.as(); - const auto& jvx = ov["x"]; - const auto& jvy = ov["y"]; - - // Some BM versions seem to store x/y as single-element arrays. - // TODO: We should be able to check size == 1 below, or just delegate to Parse, - // but that change introduces diffs. Investigate. - const ArrayValue* jvxa = jvx; - const ArrayValue* jvya = jvy; - return Parse(jvxa && jvxa->size() > 0 ? (*jvxa)[0] : jvx, &pt->fX) - && Parse(jvya && jvya->size() > 0 ? (*jvya)[0] : jvy, &pt->fY); + return Parse(ov["x"], &pt->fX) + && Parse(ov["y"], &pt->fY); } template <> -- cgit v1.2.3