Source:
<code>public SetPropertyTextResult setPropertyText(JsonRpcPeer peer, JSONObject params) { final SetPropertyTextRequest request = mObjectMapper.convertValue( params, SetPropertyTextRequest.class); final String[] parts = request.styleSheetId.split("\\.", 2); final int nodeId = Integer.parseInt(parts[0]); final String ruleName = parts[1]; final String[] keyValue = request.text.split(":", 2); final String key = keyValue[0].trim(); <START> final String value = keyValue[1].replace(";", "").trim(); <END> final SetPropertyTextResult result = new SetPropertyTextResult(); result.style = new CSSStyle(); result.style.styleSheetId = request.styleSheetId; result.style.cssProperties = new ArrayList<>(); result.style.shorthandEntries = Collections.emptyList(); mDocument.postAndWait(new Runnable() { @Override public void run() { final Object elementForNodeId = mDocument.getElementForNodeId(nodeId); if (elementForNodeId == null) { LogUtil.w("Failed to get style of an element that does not exist, nodeid=" + nodeId); return; } mDocument.setElementStyle(elementForNodeId, ruleName, key, value); mDocument.getElementStyles(elementForNodeId, ruleName, new StyleAccumulator() { @Override public void store(String name, String value, boolean isDefault) { final CSSProperty property = new CSSProperty(); property.name = name; property.value = value; result.style.cssProperties.add(property); } }); } }); return result; }</code><technical_language>time call String#replace(String, String), compiles a regular expression Pattern. This expensive! For this super simple replacement, put a utility method java.com.facebook.stetho.common.StringUtil : public static String remove(String string, char target) { int length = string.length(); StringBuilder builder = new StringBuilder(length); for (int i = 0; i < length; ++i) { char c = string.charAt(i); if (c != target) { builder.append(c); } } return builder.toString(); } (note String#split(String, int) interprets a regex, if implementation a fast path covers here)</technical_language>

Target:
public SetPropertyTextResult setPropertyText(JsonRpcPeer peer, JSONObject params) { final SetPropertyTextRequest request = mObjectMapper.convertValue( params, SetPropertyTextRequest.class); final String[] parts = request.styleSheetId.split("\\.", 2); final int nodeId = Integer.parseInt(parts[0]); final String ruleName = parts[1]; final String value; final String key; if (" ".equals(request.text)) { key = null; value = null; } else { final String[] keyValue = request.text.split(":", 2); key = keyValue[0].trim(); value = StringUtil.removeAll(keyValue[1], ';').trim(); } final SetPropertyTextResult result = new SetPropertyTextResult(); result.style = new CSSStyle(); result.style.styleSheetId = request.styleSheetId; result.style.cssProperties = new ArrayList<>(); result.style.shorthandEntries = Collections.emptyList(); mDocument.postAndWait(new Runnable() { @Override public void run() { final Object elementForNodeId = mDocument.getElementForNodeId(nodeId); if (elementForNodeId == null) { LogUtil.w("Failed to get style of an element that does not exist, nodeid=" + nodeId); return; } if (key == null) { mDocument.setElementStyle(elementForNodeId, ruleName, key, value); } mDocument.getElementStyles(elementForNodeId, ruleName, new StyleAccumulator() { @Override public void store(String name, String value, boolean isDefault) { final CSSProperty property = new CSSProperty(); property.name = name; property.value = value; result.style.cssProperties.add(property); } }); } }); return result; }