Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
使用entrySet迭代器替代keySet迭代器提高效率 #48
  • Loading branch information
Rkyzzy committed Apr 24, 2021
commit c38ad8cebbb49374e4d31bde3f6846c5343a8da8
4 changes: 2 additions & 2 deletions APIJSONORM/src/main/java/apijson/orm/AbstractParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1392,10 +1392,10 @@ public Object getValueByPath(String valuePath) {
}

//取出key被valuePath包含的result,再从里面获取key对应的value
Set<String> set = queryResultMap.keySet();
JSONObject parent = null;
String[] keys = null;
for (String path : set) {
for (Map.Entry<String,Object> entry : queryResultMap.entrySet()){
String path = entry.getKey();
if (valuePath.startsWith(path + "/")) {
try {
parent = (JSONObject) queryResultMap.get(path);
Expand Down
24 changes: 13 additions & 11 deletions APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -1341,16 +1341,17 @@ public Object getWhere(String key, boolean exactMatch) {
return where == null ? null : where.get(key);
}

Set<String> set = key == null || where == null ? null : where.keySet();
if (set != null) {
synchronized (where) {
if (where != null) {
int index;
for (String k : set) {
index = k.indexOf(key);
if (index >= 0 && StringUtil.isName(k.substring(index)) == false) {
return where.get(k);
}
if (key == null || where == null){
return null;
}
synchronized (where) {
if (where != null) {
int index;
for (Map.Entry<String,Object> entry : where.entrySet()) {
String k = entry.getKey();
index = k.indexOf(key);
if (index >= 0 && StringUtil.isName(k.substring(index)) == false) {
return where.get(k);
}
}
}
Expand Down Expand Up @@ -2289,7 +2290,8 @@ public String getSetString(RequestMethod method, Map<String, Object> content, bo
Object value;

String idKey = getIdKey();
for (String key : set) {
for (Map.Entry<String,Object> entry : content.entrySet()) {
String key = entry.getKey();
//避免筛选到全部 value = key == null ? null : content.get(key);
if (key == null || idKey.equals(key)) {
continue;
Expand Down