Imagine I had a variable called X. Say every 5 seconds, I wanted to make X = true. (it can be true or false between these 5 seconds, but gets reset to true when 5 seconds up).
It would be more efficient to check if the value is already true, and if not, reassign it to true? Or just X = true?
In other words, what will work faster?
if(x==false){ x = true; }
against
x = true;
On the one hand, the first program will not mutate a variable if it is not needed. On the other hand, the second program does not need to check that X is equal; he plunges straight.
:)
x == false 90% , x .
, , , , , .
, , - , .
/:
- , . , , .
, . , , .
, - ( , ). - x=true, .
x=true
, , , , , x=true ( ).
:
- . , 0 (x = false) , - , , x . , , , x .
, . , 0- (, , ..) , . 0- , ( true), 0- . , , , , .
Source: https://habr.com/ru/post/1749972/More articles:Get the process id of a program launched using C # Process.Start - puttyhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1749968/binding-update-adds-news-series-to-wpf-toolkit-chart-instead-of-replacingupdating-series&usg=ALkJrhgvMh2TEJh3HXYL6xNLMslJvDoWXQSetting setUp in PHPUnit - phpThe default namespace when creating an XML document is c #Convert unpack list to int - c #Where should I handle exceptions in BLL, DAL or PL? - c #Getting the button pressed after clicking () is called in Qt (C ++) - c ++M2Eclipse deploys WEB-INF to WEB-INF / classes - javaMake DialogBox wait for user action and return a boolean value in GWT - gwtUnderstanding ItemsSource and DataContext in DataGrid - .netAll Articles