Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[Android] Patch react-native-svg to cache parsed paths (#6583)

authored by

dan and committed by
GitHub
84724bb9 9f1e6486

+57
+57
patches/react-native-svg+15.3.0.patch
··· 1 + diff --git a/node_modules/react-native-svg/android/src/main/java/com/horcrux/svg/PathView.java b/node_modules/react-native-svg/android/src/main/java/com/horcrux/svg/PathView.java 2 + index 06829bd..1b15818 100644 3 + --- a/node_modules/react-native-svg/android/src/main/java/com/horcrux/svg/PathView.java 4 + +++ b/node_modules/react-native-svg/android/src/main/java/com/horcrux/svg/PathView.java 5 + @@ -14,17 +14,33 @@ import android.graphics.Paint; 6 + import android.graphics.Path; 7 + import com.facebook.react.bridge.ReactContext; 8 + 9 + +import java.util.ArrayList; 10 + +import java.util.HashMap; 11 + + 12 + +class ParsedPath { 13 + + final Path path; 14 + + final ArrayList<PathElement> elements; 15 + + 16 + + ParsedPath(Path path, ArrayList<PathElement> elements) { 17 + + this.path = path; 18 + + this.elements = elements; 19 + + } 20 + +} 21 + + 22 + @SuppressLint("ViewConstructor") 23 + class PathView extends RenderableView { 24 + private Path mPath; 25 + 26 + + // This grows forever but for our use case (static icons) it's ok. 27 + + private static final HashMap<String, ParsedPath> sPathCache = new HashMap<>(); 28 + + 29 + public PathView(ReactContext reactContext) { 30 + super(reactContext); 31 + PathParser.mScale = mScale; 32 + mPath = new Path(); 33 + } 34 + 35 + - public void setD(String d) { 36 + + void setDByParsing(String d) { 37 + mPath = PathParser.parse(d); 38 + elements = PathParser.elements; 39 + for (PathElement elem : elements) { 40 + @@ -33,6 +49,17 @@ class PathView extends RenderableView { 41 + point.y *= mScale; 42 + } 43 + } 44 + + } 45 + + 46 + + public void setD(String d) { 47 + + ParsedPath cached = sPathCache.get(d); 48 + + if (cached != null) { 49 + + mPath = cached.path; 50 + + elements = cached.elements; 51 + + } else { 52 + + setDByParsing(d); 53 + + sPathCache.put(d, new ParsedPath(mPath, elements)); 54 + + } 55 + invalidate(); 56 + } 57 +