File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -261,10 +261,16 @@ int main(void) {
261
261
std::printf (" Welcome to the Fork Union N-Body simulation!\n " );
262
262
263
263
// Read env vars
264
- std::size_t n = std::stoull (std::getenv (" NBODY_COUNT" ) ?: " 0" );
265
- std::size_t const iterations = std::stoull (std::getenv (" NBODY_ITERATIONS" ) ?: " 1000" );
266
- std::string_view const backend = std::getenv (" NBODY_BACKEND" ) ? std::getenv (" NBODY_BACKEND" ) : " fork_union_static" ;
267
- std::size_t threads = std::stoull (std::getenv (" NBODY_THREADS" ) ?: " 0" );
264
+ auto const n_str = std::getenv (" NBODY_COUNT" );
265
+ auto const iterations_str = std::getenv (" NBODY_ITERATIONS" );
266
+ auto const backend_str = std::getenv (" NBODY_BACKEND" );
267
+ auto const threads_str = std::getenv (" NBODY_THREADS" );
268
+
269
+ // Parse env vars and validate
270
+ std::size_t n = std::stoull (n_str ? n_str : " 0" );
271
+ std::size_t const iterations = std::stoull (iterations_str ? iterations_str : " 1000" );
272
+ std::string_view const backend = backend_str ? backend_str : " fork_union_static" ;
273
+ std::size_t threads = std::stoull (threads_str ? threads_str : " 0" );
268
274
if (threads == 0 ) threads = std::thread::hardware_concurrency ();
269
275
if (n == 0 ) n = threads;
270
276
You can’t perform that action at this time.
0 commit comments