Skip to content

Commit

Permalink
Update to avoid transformation computations when not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
raulcatena committed Apr 15, 2020
1 parent 9ba9ad4 commit 23e9377
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 153 deletions.
1 change: 1 addition & 0 deletions 3DIMC/IMCImageGenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#import "IMCPixelClassification.h"
#import "IMCComputationOnMask.h"
#import "NSArray+Statistics.h"
#import <Quartz/Quartz.h>

@implementation IMCImageGenerator

Expand Down
10 changes: 8 additions & 2 deletions 3DIMC/IMCLoader.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,18 @@ +(NSString *)fileSubroutine:(NSString *)path{

NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:path];
unsigned long long fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil] fileSize];
NSData *nsData = [handle readDataOfLength:MIN(FILE_SAMPLE_BYTES, fileSize)];//This way I don't need to read the whole file
NSData *nsData = [handle readDataOfLength:MAX(FILE_SAMPLE_BYTES, fileSize)];//This way I don't need to read the whole file
[handle closeFile];
//NSData *nsData = [NSData dataWithContentsOfFile:path options:NSDataReadingUncached error:&error];
//NSData *nsData = [NSData dataWithContentsOfURL:url options:NSDataReadingMappedIfSafe error:&error];
NSMutableData * subdata = [NSMutableData dataWithCapacity:fileSize/10];
char * byts = (char *)nsData.bytes;
for (char * i = 0; i < byts + fileSize; i += 10){
[subdata appendBytes:i length:1];
}
if(error)NSLog(@"Error__ %@", error);
if (nsData)
return [nsData MD5];
return [subdata MD5];
return nil;
}

Expand Down Expand Up @@ -201,6 +206,7 @@ -(void)openImagesFromURL:(NSArray<NSURL *> *)urls{////TODO address of int for lo
if (checkSum)[self setCheckSum:checkSum filePath:url.path];
}
}

[self updateFileWrappers];
[self updateOrderedImageList];
}
Expand Down
Loading

0 comments on commit 23e9377

Please sign in to comment.