Revision: 13819
http://sourceforge.net/p/skim-app/code/13819
Author: hofman
Date: 2023-12-01 10:13:51 +0000 (Fri, 01 Dec 2023)
Log Message:
-----------
use fast enumeration
Modified Paths:
--------------
trunk/SkimNotes/PDFDocument_SKNExtensions.m
trunk/SkimNotes/SKNExtendedAttributeManager.m
trunk/SkimNotes/SKNUtilities.m
trunk/SkimNotes/skimpdf.m
Modified: trunk/SkimNotes/PDFDocument_SKNExtensions.m
===================================================================
--- trunk/SkimNotes/PDFDocument_SKNExtensions.m 2023-11-30 23:40:47 UTC (rev
13818)
+++ trunk/SkimNotes/PDFDocument_SKNExtensions.m 2023-12-01 10:13:51 UTC (rev
13819)
@@ -133,15 +133,13 @@
}
- (NSArray *)addSkimNotesWithProperties:(NSArray *)noteDicts {
- NSEnumerator *e = [noteDicts objectEnumerator];
PDFAnnotation *annotation;
- NSDictionary *dict;
NSMutableArray *notes = [NSMutableArray array];
if ([self pageCount] == 0) return nil;
// create new annotations from the dictionary and add them to their page
and to the document
- while (dict = [e nextObject]) {
+ while (NSDictionary *dict in noteDicts) {
NSUInteger pageIndex = [[dict
objectForKey:SKNPDFAnnotationPageIndexKey] unsignedIntegerValue];
if ([[dict objectForKey:SKNPDFAnnotationTypeKey]
isEqualToString:SKNWidgetString]) {
if (pageIndex >= [self pageCount])
Modified: trunk/SkimNotes/SKNExtendedAttributeManager.m
===================================================================
--- trunk/SkimNotes/SKNExtendedAttributeManager.m 2023-11-30 23:40:47 UTC
(rev 13818)
+++ trunk/SkimNotes/SKNExtendedAttributeManager.m 2023-12-01 10:13:51 UTC
(rev 13819)
@@ -193,12 +193,10 @@
return nil;
}
- NSEnumerator *e = [attrNames objectEnumerator];
NSMutableDictionary *attributes = [NSMutableDictionary
dictionaryWithCapacity:[attrNames count]];
NSData *data = nil;
- NSString *attrName = nil;
- while((attrName = [e nextObject])){
+ for (NSString *attrName in attrNames){
data = [self extendedAttributeNamed:attrName atPath:path
traverseLink:follow error:&anError];
if(data != nil){
[attributes setObject:data forKey:attrName];
@@ -540,9 +538,7 @@
else
xopts = XATTR_NOFOLLOW;
- NSEnumerator *e = [allAttributes objectEnumerator];
- NSString *attrName;
- while ((attrName = [e nextObject])) {
+ for (NSString *attrName in allAttributes) {
status = removexattr(fsPath, [attrName UTF8String], xopts);
Modified: trunk/SkimNotes/SKNUtilities.m
===================================================================
--- trunk/SkimNotes/SKNUtilities.m 2023-11-30 23:40:47 UTC (rev 13818)
+++ trunk/SkimNotes/SKNUtilities.m 2023-12-01 10:13:51 UTC (rev 13819)
@@ -77,10 +77,8 @@
NSString *SKNSkimTextNotes(NSArray *noteDicts) {
NSMutableString *textString = [NSMutableString string];
- NSEnumerator *dictEnum = [noteDicts objectEnumerator];
- NSDictionary *dict;
- while (dict = [dictEnum nextObject]) {
+ for (NSDictionary *dict in noteDicts) {
NSString *type = [dict objectForKey:NOTE_TYPE_KEY];
if ([type isEqualToString:NOTE_WIDGET_TYPE])
@@ -111,10 +109,8 @@
NSData *SKNSkimRTFNotes(NSArray *noteDicts) {
NSMutableAttributedString *attrString = [[[NSMutableAttributedString
alloc] init] autorelease];
- NSEnumerator *dictEnum = [noteDicts objectEnumerator];
- NSDictionary *dict;
- while (dict = [dictEnum nextObject]) {
+ for (NSDictionary *dict in noteDicts) {
NSString *type = [dict objectForKey:NOTE_TYPE_KEY];
if ([type isEqualToString:NOTE_WIDGET_TYPE])
Modified: trunk/SkimNotes/skimpdf.m
===================================================================
--- trunk/SkimNotes/skimpdf.m 2023-11-30 23:40:47 UTC (rev 13818)
+++ trunk/SkimNotes/skimpdf.m 2023-12-01 10:13:51 UTC (rev 13819)
@@ -376,10 +376,9 @@
for (i = 0; i < iMax; i++) {
PDFPage *page = [pdfDoc pageAtIndex:i];
NSPoint pageOrigin = [page
boundsForBox:kPDFDisplayBoxMediaBox].origin;
- NSEnumerator *e = [[[[page annotations] copy] autorelease]
objectEnumerator];
- PDFAnnotation *annotation;
+ NSArray *annotations = [[page annotations] copy];
- while ((annotation = [e nextObject])) {
+ for (PDFAnnotation *annotation in annotations) {
if ([convertibleTypes containsObject:[annotation type]]) {
NSDictionary *note = [annotation SkimNoteProperties];
if ([[annotation type] isEqualToString:SKNTextString])
{
@@ -418,6 +417,7 @@
[page removeAnnotation:annotation];
}
}
+ [annotations release];
}
if ([notes count] > [inNotes count]) {
@@ -439,10 +439,8 @@
NSArray *notes1 = [fm
readSkimNotesFromExtendedAttributesAtURL:inURL error:NULL];
NSArray *notes2 = [fm
readSkimNotesFromExtendedAttributesAtURL:inURL2 error:NULL];
NSMutableArray *notes = [NSMutableArray arrayWithArray:notes1];
- NSEnumerator *e = [notes2 objectEnumerator];
- NSDictionary *note;
- while ((note = [e nextObject])) {
+ for (NSDictionary *note in notes2) {
NSMutableDictionary *mutableNote = [note mutableCopy];
NSUInteger pageIndex = [[note
objectForKey:SKNPDFAnnotationPageIndexKey] unsignedIntegerValue] + count;
[mutableNote setObject:[NSNumber
numberWithUnsignedInteger:pageIndex] forKey:SKNPDFAnnotationPageIndexKey];
@@ -509,10 +507,8 @@
NSArray *inNotes = [fm
readSkimNotesFromExtendedAttributesAtURL:inURL error:NULL];
NSMutableArray *notes = [NSMutableArray array];
- NSEnumerator *e = [inNotes objectEnumerator];
- NSDictionary *note;
- while ((note = [e nextObject])) {
+ for (NSDictionary *note in inNotes) {
NSUInteger pageIndex = [[note
objectForKey:SKNPDFAnnotationPageIndexKey] unsignedIntegerValue];
if ([indexes containsIndex:pageIndex]) {
NSUInteger newPageIndex = [indexes
countOfIndexesInRange:NSMakeRange(0, pageIndex)];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit