there is
int array[100] = {};
faster than
int array[100]; for(int i=0; i<100; ++i){ array[i] = 0; }
Or are they equal? What are the differences, if any?
Initialization of non-statically distributed arrays may well be implemented identically for both options shown. You will need to measure or view the created assembly.
( ++), UNIX BSS . BSS , . , , . ( , , , , .)
, , (
, , , . , . array , . , 0 , . .
array
0
, 0, , .
:
, , , . , , , . O (1), .
- O (N). , O (N), for. , , for, .
, , . for .
This will initialize the array by default - this means that for basic (scalar) types, the entire array will be correctly initialized to zero and indeed O (1) times. since its compiler implementation must be optimized.
here the programmer rises and takes responsibility for initializing the array. Now it depends on how well the compiler optimization code is written to answer the question of whether it matches the previous initialization or may not match.
Source: https://habr.com/ru/post/1531110/More articles:Why is the `fill ()` processing with alpha never completely filled? - processingHow to programmatically install TextBlock Foreground Hex Color - windows-phone-8StackOverflow when checking for one row in another - javaView owner event question OnClickListener owner event - androidIn the listview adapter, replace the image with a click of this image - androidC ++ "namespace" - c ++Eclipse does not work correctly after update - androidhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1531113/cant-create-avd-or-test-any-application-with-avd-after-update-build-tools-to-226&usg=ALkJrhjJhUTXQtNoPkGpzeF2SVgpsCHk7wHow to call a function in ng-click, which is defined in the factory service - javascriptWhy does Win32 have no problem with the zombie stream? - c ++All Articles