Why creating a Chinese text frameset was extremely slow in iOS5

I found that using CTFramesetterCreateWithAttributedString to create a Chinese string frameset in iOS5 was very slow, but fast in iOS4.

I missed the test like this: (chinese.txt contains 77571 Chinese characters and english.txt contains 233727 characters)

 NSString *englishCtn = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@/%@", [self documentDirectory], @"english.txt"] encoding:NSUTF8StringEncoding error:nil];
 NSAttributedString *englishCtnA = [[NSAttributedString alloc] initWithString:englishCtn];
 NSString *chineseCtn = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@/%@", [self documentDirectory], @"chinese.txt"] encoding:NSUTF8StringEncoding error:nil];
 NSAttributedString *chineseCtnA = [[NSAttributedString alloc] initWithString:chineseCtn];

double start = [[NSDate date] timeIntervalSince1970];
CTFramesetterCreateWithAttributedString((CFAttributedStringRef)englishCtnA);
NSLog(@"english length:%d time %f", englishCtn.length, ([[NSDate date] timeIntervalSince1970] - start) * 1000);

start = [[NSDate date] timeIntervalSince1970];
CTFramesetterCreateWithAttributedString((CFAttributedStringRef)chineseCtnA);
NSLog(@"chinese length:%d time %f", chineseCtnA.length, ([[NSDate date] timeIntervalSince1970] - start) * 1000);

      

in iOS 5 the result is:

chinese length: 77571 time: 12140.347004

english length: 233727 times: 75.886011

in iOS 4 the result is:

chinese length: 77571 Time: 53.114176

english length: 233727 times: 55.696011

I am using the xCode tool time profiler to see what happens, I found that the TRun :: GetNextLigatureCandidateCharRange (long) function takes most of the time, I don’t know how to optimize, help

+3


source to share


1 answer


Parts of the C ++ runtime were pretty much, if not completely, added in iOS 5, and that's where it fails. For me, this suggests that you should file a bug report with apple or open a request in your account if you have others.



0


source







All Articles