Skip to content

Commit

Permalink
perf: do not update baidu cookie and bing host when initializing (#467)
Browse files Browse the repository at this point in the history
* perf: do not update baidu cookie when initializing

* perf: do not init EZBingRequest when initializing Bing service

* perf: do not update Bing host when initializing Bing service
  • Loading branch information
tisfeng authored Mar 22, 2024
1 parent 2e25bd0 commit 968e4f0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
9 changes: 5 additions & 4 deletions Easydict/Feature/Service/Baidu/EZBaiduTranslate.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ @implementation EZBaiduTranslate

- (instancetype)init {
if (self = [super init]) {
// When debug, we should not call this method too much.
#if !DEBUG
[self updateCookieAndToken];
#endif
/**
Previously, in order to optimize the request experience, the cookie and token would be updated when initializing the service, [self updateCookieAndToken], but this would cause them to be frequently called under certain circumstances, so I removed it.
FIX https://github.com/tisfeng/Easydict/issues/466
*/
}
return self;
}
Expand Down
8 changes: 0 additions & 8 deletions Easydict/Feature/Service/Bing/EZBingRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ @implementation EZBingRequest
- (instancetype)init {
if (self = [super init]) {
_canRetryFetchHost = YES;

[self fetchBingHost:^{
[self fetchBingConfig:^{

} failure:^(NSError *error) {

}];
}];
}
return self;
}
Expand Down
9 changes: 8 additions & 1 deletion Easydict/Feature/Service/Bing/EZBingService.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,18 @@ @implementation EZBingService
- (instancetype)init {
if (self = [super init]) {
_canRetry = YES;
_request = [[EZBingRequest alloc] init];
NSLog(@"init Bing service");
}
return self;
}

- (EZBingRequest *)request {
if (!_request) {
_request = [[EZBingRequest alloc] init];
}
return _request;
}

#pragma mark - override

- (EZQueryTextType)intelligentQueryTextType {
Expand Down

0 comments on commit 968e4f0

Please sign in to comment.