@@ -1527,10 +1527,12 @@ public AbstractSQLConfig setCombine(Map<String, List<String>> combine) {
1527
1527
public Object getWhere (String key ) {
1528
1528
return getWhere (key , false );
1529
1529
}
1530
+ //CS304 Issue link: https://github.com/Tencent/APIJSON/issues/48
1530
1531
/**
1531
- * @param key
1532
- * @param exactMatch
1532
+ * @param key - the key passed in
1533
+ * @param exactMatch - whether it is exact match
1533
1534
* @return
1535
+ * <p>use entrySet+getValue() to replace keySet+get() to enhance efficiency</p>
1534
1536
*/
1535
1537
@ JSONField (serialize = false )
1536
1538
@ Override
@@ -1539,16 +1541,17 @@ public Object getWhere(String key, boolean exactMatch) {
1539
1541
return where == null ? null : where .get (key );
1540
1542
}
1541
1543
1542
- Set <String > set = key == null || where == null ? null : where .keySet ();
1543
- if (set != null ) {
1544
- synchronized (where ) {
1545
- if (where != null ) {
1546
- int index ;
1547
- for (String k : set ) {
1548
- index = k .indexOf (key );
1549
- if (index >= 0 && StringUtil .isName (k .substring (index )) == false ) {
1550
- return where .get (k );
1551
- }
1544
+ if (key == null || where == null ){
1545
+ return null ;
1546
+ }
1547
+ synchronized (where ) {
1548
+ if (where != null ) {
1549
+ int index ;
1550
+ for (Map .Entry <String ,Object > entry : where .entrySet ()) {
1551
+ String k = entry .getKey ();
1552
+ index = k .indexOf (key );
1553
+ if (index >= 0 && StringUtil .isName (k .substring (index )) == false ) {
1554
+ return entry .getValue ();
1552
1555
}
1553
1556
}
1554
1557
}
@@ -2480,11 +2483,13 @@ public static JSONArray newJSONArray(Object obj) {
2480
2483
public String getSetString () throws Exception {
2481
2484
return getSetString (getMethod (), getContent (), ! isTest ());
2482
2485
}
2486
+ //CS304 Issue link: https://github.com/Tencent/APIJSON/issues/48
2483
2487
/**获取SET
2484
- * @param method
2485
- * @param content
2488
+ * @param method -the method used
2489
+ * @param content -the content map
2486
2490
* @return
2487
- * @throws Exception
2491
+ * @throws Exception
2492
+ * <p>use entrySet+getValue() to replace keySet+get() to enhance efficiency</p>
2488
2493
*/
2489
2494
@ JSONField (serialize = false )
2490
2495
public String getSetString (RequestMethod method , Map <String , Object > content , boolean verifyName ) throws Exception {
@@ -2497,7 +2502,8 @@ public String getSetString(RequestMethod method, Map<String, Object> content, bo
2497
2502
Object value ;
2498
2503
2499
2504
String idKey = getIdKey ();
2500
- for (String key : set ) {
2505
+ for (Map .Entry <String ,Object > entry : content .entrySet ()) {
2506
+ String key = entry .getKey ();
2501
2507
//避免筛选到全部 value = key == null ? null : content.get(key);
2502
2508
if (key == null || idKey .equals (key )) {
2503
2509
continue ;
@@ -2510,7 +2516,7 @@ public String getSetString(RequestMethod method, Map<String, Object> content, bo
2510
2516
} else {
2511
2517
keyType = 0 ; //注意重置类型,不然不该加减的字段会跟着加减
2512
2518
}
2513
- value = content . get ( key );
2519
+ value = entry . getValue ( );
2514
2520
key = getRealKey (method , key , false , true , verifyName );
2515
2521
2516
2522
setString += (isFirst ? "" : ", " ) + (getKey (key ) + " = " + (keyType == 1 ? getAddString (key , value ) : (keyType == 2
0 commit comments