Note. I know exactly what a property is. This question is about performance.
Using self.fooBar to access READ seems like a waste of time for me. Unnecessary Objective-C messaging continues. Getters usually just go along the ivar, so while heβs sure that no sensible getter method will be written, I think it's great to get around this heavy guy.
Objective-C messaging is about 20 times slower than direct calls. So if there is some high-performance high-frequency code with hundreds of properties that can be used, maybe this helps a lot to avoid unessessary Objective-C messages?
Or am I wasting my time thinking about this?
This kind of premature optimization should really be postponed until you notice or measure (using Instru.app) the real problem.
Do not be offended, but you are probably wasting your time thinking about it. If you do not have code that accesses this property thousands of times per second, then you will not see differences in performance.
getters , . getter self ( ) , gett self.ivar, getter - .
self.ivar
( self.ivar ?)
, self.ivar self->ivar, :
self->ivar
atomic, self.ivar
atomic
spin_lock(&ivar_lock); id retval = [ivar retain]; spin_unlock(&ivar_lock); return [retval autorelease];
id
spin_lock(&ivar_lock); spin_lock(&destination_lock); memcpy(&destination, &ivar, sizeof(ivar)); spin_unlock(&ivar_lock); spin_unlock(&destination_lock);
. , nonatomic.
nonatomic
. getter - . , .
, , , - , IVAR .
( ). ivar, , , , . , , , .. ..
, , . , - -foobar, @ "BOO", , superClass -printFooBar @ ", ", foobar , self.foobar?
accessor , , , , . , " " , " ", .
, , , ivar , . , , - getter ( ..), .
, . OO, , Objective-C: "getter" "setter" , KVO. ivars, , , .
, " ", , , .
Source: https://habr.com/ru/post/1747214/More articles:The program crashes after trying to use a newly created file. C # - c #In SharePoint, how can I include the "Error ID" column of the problem list in the details form (DispForm.aspx) and / or email alerts? - sharepointHow does this print style sheet work? - cssUses jquery to call a WCF data service from a user interface that violates the MVC pattern - jqueryShould Wordpress be used to create a real estate site? - wordpressSmoothing a table containing rows that reference other rows in SQL Server 2005 - sqlHow to save three different text alignments in one CSS field? - htmlSearch for image tag using alt text - javascriptMake Website IIS7.5 - visual-studio-2010Show .Net assembly properties, including the public key in Windows Explorer - .netAll Articles