• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Performance problems with doubleClickAtIndex
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Performance problems with doubleClickAtIndex


  • Subject: Re: Performance problems with doubleClickAtIndex
  • From: "Mark Munz" <email@hidden>
  • Date: Sat, 8 Nov 2008 13:09:28 -0800

Here is the basic approach I'm using. I commented out the replace code
to focus on the the performance of the actual search. If I set the
granularity such that doubleClickAtIndex: is not used
(FindTypeContains), the performance is reasonable. Otherwise, the
performance is as described earlier. I borrowed the "find word"
technique from a previous posting on here.

The performance was OK on a 1.5MB sample, but seems to really bog down
somewhere between 1.5-3.0MB.

If The FindPanel is also using doubleClickAtIndex:, then I'm guessing
there is something wrong with my code or I'm missing a trick to get
the better performance of the FindPanel.

- (void)exampleReplaceAll:(NSMutableAttributedString*)inoutText
{
	NSRange		aRange;
	NSRange		matchRange;
	NSString*   workString;
	unsigned	searchOptions = NSBackwardsSearch;

	// instance variables used in this routine

	//NSString* findString;
	//NSString* replaceString;
	//int granularity;

	workString = [inoutText string];
	aRange  = NSMakeRange(0,[workString length]);
	if ([findString length] == 0)
	{
		matchRange = NSMakeRange(0,[workString length]);
	}
	else
	{
		matchRange = [workString rangeOfString:findString
options:searchOptions range:aRange];
	}
	BOOL matchSuccess = NO;

	while (matchRange.location != NSNotFound)
	{
		matchSuccess = YES;
		NSRange wordRange;

		if (granularity != FindTypeContains)
		{
			// only do the doubleClickAtIndex: test if we actually need it.
			matchSuccess = NO;
			[inoutText doubleClickAtIndex:matchRange.location];
		}

		if ( (granularity == FindTypeWholeWord) &&
(NSEqualRanges(matchRange, wordRange)) )
		{
			matchSuccess = YES;
		}
		else if ( (granularity == FindTypeStartsWith) &&
(matchRange.location == wordRange.location) )
		{
			matchSuccess = YES;
		}
		else if ( (granularity == FindTypeEndsWith) &&
(NSMaxRange(matchRange) == NSMaxRange(wordRange) ) )
		{
			matchSuccess = YES;
		}

		//if (matchSuccess)
		//{
		//	[inoutText replaceCharactersInRange:matchRange withString:replaceString];
		//}
		aRange.length = matchRange.location;
		matchRange = [workString rangeOfString:findString
options:searchOptions range:aRange];
	}
}


Any help in understanding this issue is appreciated.

Thanks.

Mark Munz


On Fri, Nov 7, 2008 at 10:16 AM, Douglas Davidson <email@hidden> wrote:
>
> On Nov 5, 2008, at 9:37 PM, Mark Munz wrote:
>
>> The same basic test using the FindPanel's ReplaceAll (with Full word
>> option) takes under 1 second to complete on the same text. I thought I
>> read that FindPanel was also using doubleClickAtIndex:. The
>> performance difference seems to hint that it is not, or that I am
>> missing something.
>
> The find panel does currently use doubleClickAtIndex:, but perhaps the usage
> pattern is different from your case.  One alternative you might consider is
> the use of CFStringTokenizer.
>
> Douglas Davidson
>
>



--
Mark Munz
unmarked software
http://www.unmarked.com/
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Performance problems with doubleClickAtIndex (From: "Mark Munz" <email@hidden>)
 >Re: Performance problems with doubleClickAtIndex (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Re: Crash in NSFileManager
  • Next by Date: Re: Crash in NSFileManager
  • Previous by thread: Re: Performance problems with doubleClickAtIndex
  • Next by thread: Core data, NSArrayController and different nibs
  • Index(es):
    • Date
    • Thread