小编dma*_*ach的帖子

为什么CoreAnimation似乎正在缓存表示层副本?

所以我们遇到了一些有趣的问题,看起来似乎是表示层的缓存,我们想知道其他人是否看到这个,以及我们可以做些什么变通办法.

我们有一些自己的属性,我们隐含动画.我们通过将它们声明为属性并动态合成它们来做到这一点:

@interface GOOLayer : CALayer
@property float gooValue;
@end

NSString *const kGOOLayerValueKey = @"gooValue";

@implementation GOOLayer

@dynamic gooValue;

- (id)initWithLayer:(id)layer {
  if ((self = [super initWithLayer:layer])) {
    id value = [layer valueForKey:kGOOLayerValueKey];
    [self setValue:value forKey:kGOOLayerValueKey];
  }
  return self;
}

- (id<CAAction>)actionForKey:(NSString *)event {
  id <CAAction> action = [super actionForKey:event];
  if (action == nil && [event isEqual:kGOOLayerValueKey]) {
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:event];
    animation.fromValue = [self.presentationLayer valueForKey:event];
    animation.duration =  [CATransaction animationDuration];
    return animation;
  }
  return action;
}

- (void)display { …
Run Code Online (Sandbox Code Playgroud)

macos core-animation objective-c ios

7
推荐指数
1
解决办法
1523
查看次数

为什么clang没有用NRVO优化这个?

我想之所以一个相当不错的C++编译器11(铛)未优化的代码,并想知道如果这里有人有意见.

#include <iostream>
#define SLOW

struct A {
  A() {}
  ~A() { std::cout << "A d'tor\n"; }
  A(const A&) { std::cout << "A copy\n"; }
  A(A&&) { std::cout << "A move\n"; }
  A &operator =(A) { std::cout << "A copy assignment\n"; return *this; }
};

struct B {
  // Using move on a sink. 
  // Nice talk at Going Native 2013 by Sean Parent.
  B(A foo) : a_(std::move(foo)) {}  
  A a_;
};

A MakeA() {
  return A();
}

B MakeB() …
Run Code Online (Sandbox Code Playgroud)

c++ optimization nrvo c++11

7
推荐指数
1
解决办法
880
查看次数

哪些环境变量控制着模型?

有很多环境变量可以控制dyld的启动,其中一些对于调试性能问题非常有用。并非所有文件都记录在案。

macos xcode dyld ios

7
推荐指数
1
解决办法
655
查看次数

标签 统计

ios ×2

macos ×2

c++ ×1

c++11 ×1

core-animation ×1

dyld ×1

nrvo ×1

objective-c ×1

optimization ×1

xcode ×1