Use std::map/set instead of C arrays

These types come with a find() method and avoids having to use helper functions to get the begin/end of the array (for linear search).
This commit is contained in:
Allan Odgaard
2012-09-20 01:22:10 +02:00
parent a9ba549cda
commit ebab500ba3
18 changed files with 78 additions and 88 deletions

View File

@@ -374,11 +374,11 @@ static BOOL MyEvent (NSEvent* anEvent, NSView* aView)
{
if([anEvent window] == [aView window])
{
static std::string const ArrowLeftRight[] = { "~" + utf8::to_s(NSLeftArrowFunctionKey), "~" + utf8::to_s(NSRightArrowFunctionKey) };
static std::set<std::string> const ArrowLeftRight = { "~" + utf8::to_s(NSLeftArrowFunctionKey), "~" + utf8::to_s(NSRightArrowFunctionKey) };
if([anEvent type] == NSLeftMouseUp)
return NSMouseInRect([aView convertPoint:[anEvent locationInWindow] fromView:nil], [aView frame], [aView isFlipped]);
else if([anEvent type] == NSKeyDown && [[aView window] firstResponder] == aView)
return oak::contains(beginof(ArrowLeftRight), endof(ArrowLeftRight), to_s(anEvent));
return ArrowLeftRight.find(to_s(anEvent)) != ArrowLeftRight.end();
}
return NO;
}