Revision: 22108
          http://sourceforge.net/p/bibdesk/svn/22108
Author:   hofman
Date:     2018-03-07 21:56:37 +0000 (Wed, 07 Mar 2018)
Log Message:
-----------
use fast enumeration

Modified Paths:
--------------
    trunk/bibdesk/BDSKBibTeXWebParser.m

Modified: trunk/bibdesk/BDSKBibTeXWebParser.m
===================================================================
--- trunk/bibdesk/BDSKBibTeXWebParser.m 2018-03-07 16:02:35 UTC (rev 22107)
+++ trunk/bibdesk/BDSKBibTeXWebParser.m 2018-03-07 21:56:37 UTC (rev 22108)
@@ -64,18 +64,19 @@
     AGRegex *bibtexRegex = [AGRegex regexWithPattern:@"@[[:alpha:]]+[ 
\\t]*[{(]"];
     
     NSArray *matches = [bibtexRegex findAllInString:text];
-    NSUInteger i, iMax = [matches count];
     
-    for (i = 0; i < iMax; i++) {
-        NSRange range = [[matches objectAtIndex:i] range];
+    for (AGRegexMatch *match in matches) {
+        NSRange range = [match range];
         NSUInteger closeLoc = [text 
indexOfRightBracketMatchingLeftBracketAtIndex:NSMaxRange(range) - 1];
 
         if (closeLoc != NSNotFound) {
-            NSString *string = [text 
substringWithRange:NSMakeRange(range.location, closeLoc + 1 - range.location)];
-            NSError *error = nil;
+            range.length = closeLoc + 1 - range.location;
+            NSString *string = [text substringWithRange:range];
             
             if ([BDSKBibTeXParser canParseString:string]) {
+                NSError *error = nil;
                 NSArray *bibtexItems = [BDSKBibTeXParser 
itemsFromString:string owner:[self delegate] error:&error];
+                
                 if ([bibtexItems count] == 1 && [error 
isLocalErrorWithCode:kBDSKBibTeXParserFailed] == NO)
                     [items addObjectsFromArray:bibtexItems];
             }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to