Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 6cb4afe

Browse files
committed
[ios] #3979 cleanup
1 parent d14bdb8 commit 6cb4afe

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

platform/darwin/src/NSData+MGLAdditions.mm

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@ - (NSData *)mgl_compressedData
99
std::string string(static_cast<const char*>(self.bytes), self.length);
1010
std::string compressed_string = mbgl::util::compress(string);
1111

12-
return [NSData dataWithBytes:(void *) compressed_string.c_str() length:compressed_string.length()];
12+
return [NSData dataWithBytes:&compressed_string[0] length:compressed_string.length()];
1313
}
1414

1515
- (NSData *)mgl_decompressedData
1616
{
1717
std::string string(static_cast<const char*>(self.bytes), self.length);
1818
std::string decompressed_string = mbgl::util::decompress(string);
1919

20-
NSString *decompressedString = @(decompressed_string.c_str());
21-
22-
return [decompressedString dataUsingEncoding:NSUTF8StringEncoding];
20+
return [NSData dataWithBytes:&decompressed_string[0] length:decompressed_string.length()];
2321
}
2422

2523
@end

platform/ios/test/MGLNSDataAdditionsTests.m

+7-6
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,20 @@ - (void)testCompressDecompress
2222

2323
NSArray *decompressedArray = [NSJSONSerialization JSONObjectWithData:decompressedData options:0 error:nil];
2424

25-
XCTAssertTrue([originalArray isEqualToArray:decompressedArray], @"originalDict and decompressedDict should be equal");
25+
XCTAssertTrue([originalArray isEqualToArray:decompressedArray], @"originalArray and decompressedArray should be equal");
2626
}
2727

2828
- (NSArray *)mockDataWithCount:(NSUInteger)count
2929
{
3030
NSMutableArray *array = [NSMutableArray array];
31-
for (NSUInteger i=0;i<count;i++) {
32-
33-
NSTimeInterval ts = [[NSDate date] timeIntervalSince1970];
31+
32+
for (NSUInteger i=0;i<count;i++)
33+
{
3434
[array addObject:@{@"lat": @([self safeValueBetween:-90 and:90]),
35-
@"lng": @([self safeValueBetween:-190 and:190]),
36-
@"timestamp": @((floor(ts) * 100) / 100)}];
35+
@"lng": @([self safeValueBetween:-180 and:180]),
36+
@"timestamp": @((floor([NSDate date].timeIntervalSince1970) * 100) / 100)}];
3737
}
38+
3839
return array;
3940
}
4041

0 commit comments

Comments
 (0)