Skip to content

Commit 47961e3

Browse files
committed
Parser 移除没必要的方法 parseCorrectResponse
1 parent 5c682cb commit 47961e3

File tree

3 files changed

+15
-33
lines changed

3 files changed

+15
-33
lines changed

APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,14 +852,17 @@ public JSONObject onSQLExecute() throws Exception {
852852
if (list != null) {
853853
String arrayPath = parentPath.substring(0, parentPath.lastIndexOf("[]") + 2);
854854

855+
long startTime = System.currentTimeMillis();
855856
for (int i = 1; i < list.size(); i++) { // 从 1 开始,0 已经处理过
856-
JSONObject obj = parser.parseCorrectResponse(table, list.get(i));
857-
list.set(i, obj);
857+
JSONObject obj = list.get(i);
858858

859859
if (obj != null) {
860860
parser.putQueryResult(arrayPath + "/" + i + "/" + name, obj); //解决获取关联数据时requestObject里不存在需要的关联数据
861861
}
862862
}
863+
864+
long endTime = System.currentTimeMillis();
865+
Log.e(TAG, "onSQLExecute for (int i = 1; i < list.size(); i++) startTime = " + startTime + "; endTime = " + endTime + "; duration = " + (endTime - startTime));
863866

864867
parser.putArrayMainCache(arrayPath, list);
865868
}

APIJSONORM/src/main/java/apijson/orm/AbstractParser.java

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -719,33 +719,6 @@ public JSONObject parseCorrectRequest() throws Exception {
719719
}
720720

721721

722-
//TODO 优化性能!
723-
/**获取正确的返回结果
724-
* @param method
725-
* @param response
726-
* @return
727-
* @throws Exception
728-
*/
729-
@Override
730-
public JSONObject parseCorrectResponse(String table, JSONObject response) throws Exception {
731-
// Log.d(TAG, "getCorrectResponse method = " + method + "; table = " + table);
732-
// if (response == null || response.isEmpty()) {//避免无效空result:{}添加内容后变有效
733-
// Log.e(TAG, "getCorrectResponse response == null || response.isEmpty() >> return response;");
734-
return response;
735-
// }
736-
//
737-
// JSONObject target = apijson.JSONObject.isTableKey(table) == false
738-
// ? new JSONObject() : getStructure(method, "Response", "model", table);
739-
//
740-
// return MethodStructure.parseResponse(method, table, target, response, new OnParseCallback() {
741-
//
742-
// @Override
743-
// protected JSONObject onParseJSONObject(String key, JSONObject tobj, JSONObject robj) throws Exception {
744-
// return getCorrectResponse(method, key, robj);
745-
// }
746-
// });
747-
}
748-
749722
/**获取Request或Response内指定JSON结构
750723
* @param table
751724
* @param method
@@ -1075,15 +1048,22 @@ public JSONArray onArrayParse(JSONObject request, String parentPath, String name
10751048
.setJoinList(onJoinParse(join, request));
10761049

10771050
JSONObject parent;
1051+
1052+
long startTime = System.currentTimeMillis();
10781053
//生成size个
10791054
for (int i = 0; i < (isSubquery ? 1 : size); i++) {
10801055
parent = onObjectParse(request, isSubquery ? parentPath : path, isSubquery ? name : "" + i, config.setType(SQLConfig.TYPE_ITEM).setPosition(i), isSubquery);
10811056
if (parent == null || parent.isEmpty()) {
10821057
break;
10831058
}
1059+
10841060
//key[]:{Table:{}}中key equals Table时 提取Table
10851061
response.add(getValue(parent, childKeys)); //null有意义
10861062
}
1063+
1064+
long endTime = System.currentTimeMillis();
1065+
Log.e(TAG, "onArrayParse for for (int i = 0; i < (isSubquery ? 1 : size); i++) startTime = " + startTime + "; endTime = " + endTime + "; duration = " + (endTime - startTime));
1066+
10871067
//Table>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
10881068

10891069

@@ -1665,7 +1645,7 @@ public JSONObject executeSQL(SQLConfig config, boolean isSubquery) throws Except
16651645
result = getSQLExecutor().execute(config, false);
16661646
}
16671647

1668-
return parseCorrectResponse(config.getTable(), result);
1648+
return result;
16691649
}
16701650
catch (Exception e) {
16711651
if (Log.DEBUG == false && e instanceof SQLException) {

APIJSONORM/src/main/java/apijson/orm/Parser.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,18 @@ public interface Parser<T> {
6464
JSONObject parseResponse(String request);
6565
JSONObject parseResponse(JSONObject request);
6666

67+
// 没必要性能还差 JSONObject parseCorrectResponse(String table, JSONObject response) throws Exception;
6768

6869

6970
JSONObject parseCorrectRequest() throws Exception;
7071

7172
JSONObject parseCorrectRequest(RequestMethod method, String tag, int version, String name, JSONObject request,
7273
int maxUpdateCount, SQLCreator creator) throws Exception;
7374

74-
JSONObject parseCorrectResponse(String table, JSONObject response) throws Exception;
75-
75+
7676
JSONObject getStructure(String table, String method, String tag, int version) throws Exception;
7777

7878

79-
8079
JSONObject onObjectParse(JSONObject request, String parentPath, String name, SQLConfig arrayConfig, boolean isSubquery) throws Exception;
8180

8281
JSONArray onArrayParse(JSONObject request, String parentPath, String name, boolean isSubquery) throws Exception;

0 commit comments

Comments
 (0)