mirror of
https://github.com/wownero/cyberwow.git
synced 2026-10-20 00:38:46 +02:00
use compute for background json parsing
This commit is contained in:
@@ -58,6 +58,8 @@ Future<http.Response> rpcHTTP(String method) async {
|
||||
}
|
||||
}
|
||||
|
||||
dynamic jsonDecode(String responseBody) => json.decode(responseBody);
|
||||
|
||||
Future<dynamic> rpc(String method, {String field}) async {
|
||||
final response = await rpcHTTP(method);
|
||||
|
||||
@@ -66,7 +68,8 @@ Future<dynamic> rpc(String method, {String field}) async {
|
||||
if (response.statusCode != 200) {
|
||||
return null;
|
||||
} else {
|
||||
final _result = json.decode(response.body)['result'];
|
||||
final _body = await compute(jsonDecode, response.body);
|
||||
final _result = _body['result'];
|
||||
final _field = field == null ? _result : _result[field];
|
||||
|
||||
return _field;
|
||||
|
||||
@@ -44,6 +44,8 @@ Future<http.Response> rpc2(String method) async {
|
||||
}
|
||||
}
|
||||
|
||||
dynamic jsonDecode(String responseBody) => json.decode(responseBody);
|
||||
|
||||
Future<String> rpc2String(String method, {String field}) async {
|
||||
final response = await rpc2(method);
|
||||
|
||||
@@ -52,7 +54,7 @@ Future<String> rpc2String(String method, {String field}) async {
|
||||
if (response.statusCode != 200) {
|
||||
return '';
|
||||
} else {
|
||||
final _body= json.decode(response.body);
|
||||
final _body = await compute(jsonDecode, response.body);
|
||||
final _field = field == null ? _body: _body[field];
|
||||
|
||||
return pretty(_field);
|
||||
|
||||
Reference in New Issue
Block a user