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

Commit 57c8246

Browse files
committed
ObjectiveC: Use uint16 and uint32 for more specified bits
1 parent 3a00a83 commit 57c8246

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

objectivec/DiffMatchPatch.m

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ - (NSString *)diff_toDelta:(NSMutableArray *)diffs;
13421342
return delta;
13431343
}
13441344

1345-
- (int)diff_digit16:(unichar)c
1345+
- (NSInteger)diff_digit16:(unichar)c
13461346
{
13471347
switch (c) {
13481348
case '0': return 0;
@@ -1382,8 +1382,8 @@ - (NSString *)diff_decodeURIWithText:(NSString *)percentEncoded
13821382
continue;
13831383
}
13841384

1385-
int byte1 = ([self diff_digit16:[percentEncoded characterAtIndex:(input+1)]] << 4) +
1386-
[self diff_digit16:[percentEncoded characterAtIndex:(input+2)]];
1385+
uint16 byte1 = ([self diff_digit16:[percentEncoded characterAtIndex:(input+1)]] << 4) +
1386+
[self diff_digit16:[percentEncoded characterAtIndex:(input+2)]];
13871387

13881388
if ((byte1 & 0x80) == 0) {
13891389
decoded[output++] = byte1;
@@ -1395,8 +1395,8 @@ - (NSString *)diff_decodeURIWithText:(NSString *)percentEncoded
13951395
return nil;
13961396
}
13971397

1398-
int byte2 = ([self diff_digit16:[percentEncoded characterAtIndex:(input+4)]] << 4) +
1399-
[self diff_digit16:[percentEncoded characterAtIndex:(input+5)]];
1398+
uint16 byte2 = ([self diff_digit16:[percentEncoded characterAtIndex:(input+4)]] << 4) +
1399+
[self diff_digit16:[percentEncoded characterAtIndex:(input+5)]];
14001400

14011401
if ((byte2 & 0xC0) != 0x80) {
14021402
return nil;
@@ -1414,8 +1414,8 @@ - (NSString *)diff_decodeURIWithText:(NSString *)percentEncoded
14141414
return nil;
14151415
}
14161416

1417-
int byte3 = ([self diff_digit16:[percentEncoded characterAtIndex:(input+7)]] << 4) +
1418-
[self diff_digit16:[percentEncoded characterAtIndex:(input+8)]];
1417+
uint16 byte3 = ([self diff_digit16:[percentEncoded characterAtIndex:(input+7)]] << 4) +
1418+
[self diff_digit16:[percentEncoded characterAtIndex:(input+8)]];
14191419

14201420
if ((byte3 & 0xC0) != 0x80) {
14211421
return nil;
@@ -1433,8 +1433,8 @@ - (NSString *)diff_decodeURIWithText:(NSString *)percentEncoded
14331433
return nil;
14341434
}
14351435

1436-
int byte4 = ([self diff_digit16:[percentEncoded characterAtIndex:(input+10)]] << 4) +
1437-
[self diff_digit16:[percentEncoded characterAtIndex:(input+11)]];
1436+
uint16 byte4 = ([self diff_digit16:[percentEncoded characterAtIndex:(input+10)]] << 4) +
1437+
[self diff_digit16:[percentEncoded characterAtIndex:(input+11)]];
14381438

14391439
if ((byte4 & 0xC0) != 0x80) {
14401440
return nil;
@@ -1443,7 +1443,7 @@ - (NSString *)diff_decodeURIWithText:(NSString *)percentEncoded
14431443
byte4 = byte4 & 0x3F;
14441444

14451445
if ((byte1 & 0xF8) == 0xF0) {
1446-
int codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) | (byte3 << 0x06) | byte4;
1446+
uint32 codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) | (byte3 << 0x06) | byte4;
14471447
if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
14481448
codePoint -= 0x010000;
14491449
decoded[output++] = ((codePoint >> 10) & 0x3FF) | 0xD800;

0 commit comments

Comments
 (0)