public void println(String x) {
synchronized (this) {
print(x);
newLine();
}
}
public String toFunctionCallString(boolean useValue, String quote) {
String s = getMethod() + "(";
Object[] args = useValue ? getValues() : getKeys();
if (args != null && args.length > 0) {
if (quote == null) {
quote = "'";
}
Object arg;
for (int i = 0; i < args.length; i++) {
arg = args[i];
s += (i <= 0 ? "" : ",") + (arg instanceof Boolean || arg instanceof Number ? arg : quote + arg + quote);
}
}
return s + ")";
}
apijson.Log这个类里使用了System.err.println(TAG + ".DEBUG: " + msg);println的实现中有锁,压测的时候会发现 qps 上不去这里可以换成 slf4j 的实现,最终使用用什么日志实现可以交由下游应用自定义
大量的 bool == false 判断
在方法中使用循环拼接字符串
比如
AbstractFunctionParser#toFunctionCallString见类
AbstractParser