Skip to content

Commit

Permalink
Improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
maicki committed Apr 10, 2017
1 parent d22d2be commit 0d1adcb
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,50 +180,50 @@ static void someFunction() {
- There are multiple ways to acquire a lock:
1. Explicitly call `.lock()` and `.unlock()` :
```objc
- (void)setContentSpacing:(CGFloat)contentSpacing
{
__instanceLock__.lock();
BOOL needsUpdate = (contentSpacing != _contentSpacing);
if (needsUpdate) {
_contentSpacing = contentSpacing;
}
__instanceLock__.unlock();

if (needsUpdate) {
[self setNeedsLayout];
}
}
- (void)setContentSpacing:(CGFloat)contentSpacing
{
__instanceLock__.lock();
BOOL needsUpdate = (contentSpacing != _contentSpacing);
if (needsUpdate) {
_contentSpacing = contentSpacing;
}
__instanceLock__.unlock();

if (needsUpdate) {
[self setNeedsLayout];
}
}

- (CGFloat)contentSpacing
{
CGFloat contentSpacing = 0.0;
__instanceLock__.lock();
contentSpacing = _contentSpacing;
__instanceLock__.unlock();
return contentSpacing;
}
- (CGFloat)contentSpacing
{
CGFloat contentSpacing = 0.0;
__instanceLock__.lock();
contentSpacing = _contentSpacing;
__instanceLock__.unlock();
return contentSpacing;
}
```
2. Create an `ASDN::MutexLocker` :
```objc
- (void)setContentSpacing:(CGFloat)contentSpacing
{
{
ASDN::MutexLocker l(__instanceLock__);
if (contentSpacing == _contentSpacing) {
return;
}
_contentSpacing = contentSpacing;
}
[self setNeedsLayout];
- (void)setContentSpacing:(CGFloat)contentSpacing
{
{
ASDN::MutexLocker l(__instanceLock__);
if (contentSpacing == _contentSpacing) {
return;
}

- (CGFloat)contentSpacing
{
ASDN::MutexLocker l(__instanceLock__);
return _contentSpacing;
}
_contentSpacing = contentSpacing;
}

[self setNeedsLayout];
}

- (CGFloat)contentSpacing
{
ASDN::MutexLocker l(__instanceLock__);
return _contentSpacing;
}
```
- Nullability
- The adoption of annotations is straightforward. The standard we adopt is using the `NS_ASSUME_NONNULL_BEGIN` and `NS_ASSUME_NONNULL_END` on all headers. Then indicate nullability for the pointers that can be so.
Expand Down

0 comments on commit 0d1adcb

Please sign in to comment.