任何人都可以在这两个代码段之间建议最佳性能代码
代码1
Map token_map = new HashMap();
for (int i = 1; i < req_tokens.length; ++i) {
String[] spl_token = null;
spl_token = req_tokens[i].trim().split("=");
token_map.put(spl_token[0], spl_token[1]);
}
cs_chnl_id = (String) token_map.get("ChannelId");
obj_id = (String) token_map.get("ObjectId");
channel_name = (String) token_map.get("ChannelName");
username = (String) token_map.get("Username");
pwd = (String) token_map.get("Password");
hotel_key = (String) token_map.get("Channel_hotel_key");
resId = (String) token_map.get("Res_Id");
String booking_date = (String) token_map.get("Booking_Date");
days_past = (String) token_map.get("Days_past");
代码2
for (int i = 1; i < req_tokens.length; ++i) {
String[] spl_token = null;
String key = null;
spl_token = req_tokens[i].trim().split("=");
key = spl_token[0].trim();
// initilizing cron values for instance varibles
if (key.equalsIgnoreCase("ChannelId")) {
cs_chnl_id = spl_token[1].trim();
} else if (key.equalsIgnoreCase("ObjectId")) {
objectId = spl_token[1].trim();
} else if (key.equalsIgnoreCase("ChannelName")) {
channel_name = spl_token[1].trim();
} else if (key.equalsIgnoreCase("Username")) {
username = spl_token[1].trim();
} else if (key.equalsIgnoreCase("Password")) {
pwd = spl_token[1].trim();
} else if (key.equalsIgnoreCase("Channel_hotel_key")) {
hotel_key = spl_token[1].trim();
} else if (key.equalsIgnoreCase("Res_Id")) {
resId = spl_token[1].trim();
} else if (key.equalsIgnoreCase("Booking_Date")) {
booking_date = spl_token[1].trim();
} else if (key.equalsIgnoreCase("Days_past")) {
days_past = spl_token[1].trim();
}
}