aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authoryazevnul <yazevnul@yandex-team.ru>2022-02-10 16:46:48 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:48 +0300
commit9abfb1a53b7f7b791444d1378e645d8fad9b06ed (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /util
parent8cbc307de0221f84c80c42dcbe07d40727537e2c (diff)
downloadydb-9abfb1a53b7f7b791444d1378e645d8fad9b06ed.tar.gz
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/README.md4
-rw-r--r--util/charset/benchmark/to_lower/main.cpp68
-rw-r--r--util/charset/benchmark/to_lower/metrics/main.py10
-rw-r--r--util/charset/benchmark/to_lower/metrics/ya.make26
-rw-r--r--util/charset/benchmark/to_lower/ya.make18
-rw-r--r--util/charset/benchmark/utf8_to_wide/main.cpp2
-rw-r--r--util/charset/benchmark/utf8_to_wide/metrics/main.py10
-rw-r--r--util/charset/benchmark/utf8_to_wide/metrics/ya.make26
-rw-r--r--util/charset/benchmark/ya.make20
-rw-r--r--util/charset/utf8.cpp4
-rw-r--r--util/charset/utf8.h14
-rw-r--r--util/charset/utf8_ut.cpp12
-rw-r--r--util/charset/wide.cpp680
-rw-r--r--util/charset/wide.h282
-rw-r--r--util/charset/wide_ut.cpp1500
-rw-r--r--util/datetime/base.cpp18
-rw-r--r--util/datetime/base.h108
-rw-r--r--util/datetime/base_ut.cpp40
-rw-r--r--util/datetime/cputimer.cpp12
-rw-r--r--util/datetime/cputimer.h4
-rw-r--r--util/datetime/parser.rl692
-rw-r--r--util/datetime/parser_ut.cpp94
-rw-r--r--util/digest/city.cpp4
-rw-r--r--util/digest/city.h44
-rw-r--r--util/digest/fnv.h16
-rw-r--r--util/digest/multi.h2
-rw-r--r--util/digest/multi_ut.cpp2
-rw-r--r--util/digest/murmur.cpp4
-rw-r--r--util/digest/murmur_ut.cpp2
-rw-r--r--util/digest/numeric.h18
-rw-r--r--util/digest/sequence.h2
-rw-r--r--util/digest/sequence_ut.cpp2
-rw-r--r--util/draft/date.h12
-rw-r--r--util/draft/date_ut.cpp4
-rw-r--r--util/draft/datetime.cpp10
-rw-r--r--util/draft/datetime_ut.cpp8
-rw-r--r--util/draft/enum.h8
-rw-r--r--util/draft/holder_vector.h2
-rw-r--r--util/draft/holder_vector_ut.cpp16
-rw-r--r--util/draft/ip.h2
-rw-r--r--util/draft/matrix.h10
-rw-r--r--util/draft/memory_ut.cpp4
-rw-r--r--util/folder/dirent_win.c2
-rw-r--r--util/folder/dirut.cpp36
-rw-r--r--util/folder/dirut.h4
-rw-r--r--util/folder/filelist.cpp2
-rw-r--r--util/folder/filelist.h4
-rw-r--r--util/folder/filelist_ut.cpp2
-rw-r--r--util/folder/fts.cpp102
-rw-r--r--util/folder/fts.h2
-rw-r--r--util/folder/fts_ut.cpp4
-rw-r--r--util/folder/iterator.h4
-rw-r--r--util/folder/iterator_ut.cpp4
-rw-r--r--util/folder/path.cpp64
-rw-r--r--util/folder/path.h12
-rw-r--r--util/folder/path_ut.cpp78
-rw-r--r--util/folder/pathsplit.cpp14
-rw-r--r--util/folder/pathsplit.h30
-rw-r--r--util/folder/pathsplit_ut.cpp64
-rw-r--r--util/folder/tempdir.cpp2
-rw-r--r--util/generic/adaptor_ut.cpp10
-rw-r--r--util/generic/algorithm.h24
-rw-r--r--util/generic/algorithm_ut.cpp130
-rw-r--r--util/generic/array_ref.h20
-rw-r--r--util/generic/array_ref_ut.cpp48
-rw-r--r--util/generic/array_size.h2
-rw-r--r--util/generic/array_size_ut.cpp14
-rw-r--r--util/generic/benchmark/fastclp2/main.cpp90
-rw-r--r--util/generic/benchmark/fastclp2/metrics/main.py8
-rw-r--r--util/generic/benchmark/fastclp2/metrics/ya.make26
-rw-r--r--util/generic/benchmark/fastclp2/ya.make20
-rw-r--r--util/generic/benchmark/log2/main.cpp186
-rw-r--r--util/generic/benchmark/log2/metrics/main.py8
-rw-r--r--util/generic/benchmark/log2/metrics/ya.make26
-rw-r--r--util/generic/benchmark/log2/ya.make26
-rw-r--r--util/generic/benchmark/rotate_bits/main.cpp124
-rw-r--r--util/generic/benchmark/rotate_bits/metrics/main.py8
-rw-r--r--util/generic/benchmark/rotate_bits/metrics/ya.make26
-rw-r--r--util/generic/benchmark/rotate_bits/ya.make20
-rw-r--r--util/generic/benchmark/vector_count_ctor/f.cpp46
-rw-r--r--util/generic/benchmark/vector_count_ctor/f.h18
-rw-r--r--util/generic/benchmark/vector_count_ctor/main.cpp58
-rw-r--r--util/generic/benchmark/vector_count_ctor/metrics/main.py8
-rw-r--r--util/generic/benchmark/vector_count_ctor/metrics/ya.make26
-rw-r--r--util/generic/benchmark/vector_count_ctor/ya.make28
-rw-r--r--util/generic/benchmark/ya.make22
-rw-r--r--util/generic/bitmap.h80
-rw-r--r--util/generic/bitmap_ut.cpp38
-rw-r--r--util/generic/bitops.cpp276
-rw-r--r--util/generic/bitops.h620
-rw-r--r--util/generic/bitops_ut.cpp134
-rw-r--r--util/generic/buffer.cpp10
-rw-r--r--util/generic/buffer.h4
-rw-r--r--util/generic/buffer_ut.cpp20
-rw-r--r--util/generic/cast.h42
-rw-r--r--util/generic/cast_ut.cpp50
-rw-r--r--util/generic/explicit_type.h2
-rw-r--r--util/generic/explicit_type_ut.cpp4
-rw-r--r--util/generic/fastqueue.h2
-rw-r--r--util/generic/flags.cpp30
-rw-r--r--util/generic/flags.h22
-rw-r--r--util/generic/flags_ut.cpp12
-rw-r--r--util/generic/function_ut.cpp16
-rw-r--r--util/generic/fuzz/vector/main.cpp2
-rw-r--r--util/generic/fwd.h82
-rw-r--r--util/generic/guid.cpp8
-rw-r--r--util/generic/guid.h28
-rw-r--r--util/generic/guid_ut.cpp14
-rw-r--r--util/generic/hash.h54
-rw-r--r--util/generic/hash_primes_ut.cpp4
-rw-r--r--util/generic/hash_set.h2
-rw-r--r--util/generic/hash_ut.cpp94
-rw-r--r--util/generic/intrlist.h12
-rw-r--r--util/generic/intrlist_ut.cpp2
-rw-r--r--util/generic/is_in.h8
-rw-r--r--util/generic/is_in_ut.cpp12
-rw-r--r--util/generic/iterator.h8
-rw-r--r--util/generic/iterator_range_ut.cpp12
-rw-r--r--util/generic/iterator_ut.cpp8
-rw-r--r--util/generic/lazy_value.h2
-rw-r--r--util/generic/lazy_value_ut.cpp16
-rw-r--r--util/generic/list_ut.cpp4
-rw-r--r--util/generic/map_ut.cpp28
-rw-r--r--util/generic/mapfindptr.h4
-rw-r--r--util/generic/mapfindptr_ut.cpp14
-rw-r--r--util/generic/maybe.h8
-rw-r--r--util/generic/maybe_ut.cpp70
-rw-r--r--util/generic/mem_copy.h4
-rw-r--r--util/generic/mem_copy_ut.cpp16
-rw-r--r--util/generic/objects_counter_ut.cpp8
-rw-r--r--util/generic/ptr.h58
-rw-r--r--util/generic/ptr_ut.cpp34
-rw-r--r--util/generic/queue_ut.cpp18
-rw-r--r--util/generic/refcount.h2
-rw-r--r--util/generic/scope.h40
-rw-r--r--util/generic/scope_ut.cpp6
-rw-r--r--util/generic/set_ut.cpp24
-rw-r--r--util/generic/singleton.cpp8
-rw-r--r--util/generic/singleton.h2
-rw-r--r--util/generic/singleton_ut.cpp8
-rw-r--r--util/generic/stack_ut.cpp4
-rw-r--r--util/generic/strbase.h32
-rw-r--r--util/generic/strbuf.h14
-rw-r--r--util/generic/strbuf_ut.cpp82
-rw-r--r--util/generic/string.h2
-rw-r--r--util/generic/string_transparent_hash_ut.cpp20
-rw-r--r--util/generic/string_ut.cpp56
-rw-r--r--util/generic/string_ut.h24
-rw-r--r--util/generic/typelist.h10
-rw-r--r--util/generic/typelist_ut.cpp16
-rw-r--r--util/generic/typetraits.h108
-rw-r--r--util/generic/typetraits_ut.cpp76
-rw-r--r--util/generic/ut/ya.make22
-rw-r--r--util/generic/utility.h4
-rw-r--r--util/generic/va_args.cpp6
-rw-r--r--util/generic/va_args.h12
-rwxr-xr-xutil/generic/va_args_gen.py2
-rw-r--r--util/generic/va_args_ut.cpp10
-rw-r--r--util/generic/vector_ut.cpp2
-rw-r--r--util/generic/xrange.h56
-rw-r--r--util/generic/xrange_ut.cpp20
-rw-r--r--util/generic/yexception.cpp36
-rw-r--r--util/generic/yexception.h84
-rw-r--r--util/generic/yexception_ut.cpp36
-rw-r--r--util/generic/ylimits.h4
-rw-r--r--util/generic/ylimits_ut.cpp6
-rw-r--r--util/generic/ymath.cpp16
-rw-r--r--util/generic/ymath.h10
-rw-r--r--util/generic/ymath_ut.cpp4
-rw-r--r--util/memory/blob.cpp12
-rw-r--r--util/memory/blob.h6
-rw-r--r--util/memory/blob_ut.cpp2
-rw-r--r--util/memory/pool.h6
-rw-r--r--util/memory/pool_ut.cpp2
-rw-r--r--util/memory/segmented_string_pool.h40
-rw-r--r--util/memory/segpool_alloc.h16
-rw-r--r--util/memory/smallobj.h2
-rw-r--r--util/memory/smallobj_ut.cpp14
-rw-r--r--util/memory/tempbuf.cpp4
-rw-r--r--util/memory/tempbuf.h4
-rw-r--r--util/network/address.cpp6
-rw-r--r--util/network/address.h2
-rw-r--r--util/network/address_ut.cpp10
-rw-r--r--util/network/endpoint_ut.cpp6
-rw-r--r--util/network/hostip.cpp4
-rw-r--r--util/network/init.cpp28
-rw-r--r--util/network/init.h2
-rw-r--r--util/network/interface.cpp6
-rw-r--r--util/network/iovec.h2
-rw-r--r--util/network/ip_ut.cpp4
-rw-r--r--util/network/nonblock.cpp6
-rw-r--r--util/network/pair.cpp4
-rw-r--r--util/network/poller.h2
-rw-r--r--util/network/poller_ut.cpp38
-rw-r--r--util/network/pollerimpl.h26
-rw-r--r--util/network/sock.h42
-rw-r--r--util/network/sock_ut.cpp12
-rw-r--r--util/network/socket.cpp42
-rw-r--r--util/network/socket.h12
-rw-r--r--util/network/socket_ut.cpp4
-rw-r--r--util/random/benchmark/prng/main.cpp42
-rw-r--r--util/random/benchmark/prng/metrics/main.py8
-rw-r--r--util/random/benchmark/prng/metrics/ya.make26
-rw-r--r--util/random/benchmark/prng/ya.make20
-rw-r--r--util/random/benchmark/ya.make16
-rw-r--r--util/random/common_ops.h28
-rw-r--r--util/random/common_ops_ut.cpp10
-rw-r--r--util/random/easy_ut.cpp4
-rw-r--r--util/random/entropy.cpp20
-rw-r--r--util/random/entropy.h6
-rw-r--r--util/random/entropy_ut.cpp4
-rw-r--r--util/random/fast.cpp8
-rw-r--r--util/random/fast.h14
-rw-r--r--util/random/fast_ut.cpp24
-rw-r--r--util/random/lcg_engine.h2
-rw-r--r--util/random/mersenne.h4
-rw-r--r--util/random/mersenne32.cpp4
-rw-r--r--util/random/mersenne32.h6
-rw-r--r--util/random/mersenne64.cpp4
-rw-r--r--util/random/mersenne64.h6
-rw-r--r--util/random/mersenne_ut.cpp18
-rw-r--r--util/random/normal_ut.cpp10
-rw-r--r--util/random/random_ut.cpp12
-rw-r--r--util/random/shuffle_ut.cpp8
-rw-r--r--util/str_stl.h34
-rw-r--r--util/stream/aligned.cpp2
-rw-r--r--util/stream/aligned.h20
-rw-r--r--util/stream/aligned_ut.cpp6
-rw-r--r--util/stream/buffer.h2
-rw-r--r--util/stream/buffer_ut.cpp10
-rw-r--r--util/stream/buffered.cpp30
-rw-r--r--util/stream/buffered.h18
-rw-r--r--util/stream/buffered_ut.cpp16
-rw-r--r--util/stream/debug.cpp4
-rw-r--r--util/stream/debug.h4
-rw-r--r--util/stream/direct_io.h4
-rw-r--r--util/stream/direct_io_ut.cpp108
-rw-r--r--util/stream/file.cpp6
-rw-r--r--util/stream/file.h2
-rw-r--r--util/stream/file_ut.cpp6
-rw-r--r--util/stream/format.cpp14
-rw-r--r--util/stream/format.h56
-rw-r--r--util/stream/format_ut.cpp26
-rw-r--r--util/stream/fwd.cpp2
-rw-r--r--util/stream/fwd.h190
-rw-r--r--util/stream/hex.cpp4
-rw-r--r--util/stream/hex.h6
-rw-r--r--util/stream/hex_ut.cpp6
-rw-r--r--util/stream/holder.h10
-rw-r--r--util/stream/input.cpp46
-rw-r--r--util/stream/input.h30
-rw-r--r--util/stream/input_ut.cpp20
-rw-r--r--util/stream/ios_ut.cpp24
-rw-r--r--util/stream/labeled.h2
-rw-r--r--util/stream/labeled_ut.cpp4
-rw-r--r--util/stream/length.cpp2
-rw-r--r--util/stream/length.h20
-rw-r--r--util/stream/length_ut.cpp8
-rw-r--r--util/stream/mem.cpp2
-rw-r--r--util/stream/mem.h14
-rw-r--r--util/stream/mem_ut.cpp8
-rw-r--r--util/stream/multi.cpp2
-rw-r--r--util/stream/multi.h8
-rw-r--r--util/stream/multi_ut.cpp8
-rw-r--r--util/stream/null.h4
-rw-r--r--util/stream/output.cpp52
-rw-r--r--util/stream/output.h48
-rw-r--r--util/stream/pipe.cpp14
-rw-r--r--util/stream/pipe.h4
-rw-r--r--util/stream/printf.cpp8
-rw-r--r--util/stream/printf.h6
-rw-r--r--util/stream/printf_ut.cpp14
-rw-r--r--util/stream/str.h4
-rw-r--r--util/stream/str_ut.cpp18
-rw-r--r--util/stream/tee.cpp2
-rw-r--r--util/stream/tee.h8
-rw-r--r--util/stream/tempbuf.cpp2
-rw-r--r--util/stream/tokenizer.h80
-rw-r--r--util/stream/tokenizer_ut.cpp498
-rw-r--r--util/stream/trace.h8
-rw-r--r--util/stream/walk.cpp6
-rw-r--r--util/stream/walk.h6
-rw-r--r--util/stream/walk_ut.cpp6
-rw-r--r--util/stream/zerocopy.cpp12
-rw-r--r--util/stream/zerocopy.h26
-rw-r--r--util/stream/zlib.cpp14
-rw-r--r--util/stream/zlib.h20
-rw-r--r--util/stream/zlib_ut.cpp10
-rw-r--r--util/string/ascii.h2
-rw-r--r--util/string/ascii_ut.cpp8
-rw-r--r--util/string/benchmark/float_to_string/main.cpp492
-rw-r--r--util/string/benchmark/float_to_string/metrics/main.py8
-rw-r--r--util/string/benchmark/float_to_string/metrics/ya.make26
-rw-r--r--util/string/benchmark/float_to_string/ya.make16
-rw-r--r--util/string/benchmark/subst_global/main.cpp384
-rw-r--r--util/string/benchmark/subst_global/metrics/main.py8
-rw-r--r--util/string/benchmark/subst_global/metrics/ya.make26
-rw-r--r--util/string/benchmark/subst_global/ya.make16
-rw-r--r--util/string/benchmark/ya.make20
-rw-r--r--util/string/builder.cpp2
-rw-r--r--util/string/builder_ut.cpp10
-rw-r--r--util/string/cast.cpp466
-rw-r--r--util/string/cast_ut.cpp110
-rw-r--r--util/string/escape.cpp4
-rw-r--r--util/string/escape_ut.cpp40
-rw-r--r--util/string/fuzzing/escape_c/main.cpp22
-rw-r--r--util/string/fuzzing/escape_c/ya.make24
-rw-r--r--util/string/fuzzing/ya.make12
-rw-r--r--util/string/hex.h2
-rw-r--r--util/string/hex_ut.cpp8
-rw-r--r--util/string/join_ut.cpp18
-rw-r--r--util/string/printf.cpp2
-rw-r--r--util/string/printf.h6
-rw-r--r--util/string/printf_ut.cpp10
-rw-r--r--util/string/split.h2
-rw-r--r--util/string/split_ut.cpp34
-rw-r--r--util/string/strip_ut.cpp48
-rw-r--r--util/string/subst.cpp360
-rw-r--r--util/string/subst.h64
-rw-r--r--util/string/subst_ut.cpp90
-rw-r--r--util/string/type.cpp8
-rw-r--r--util/string/type_ut.cpp12
-rw-r--r--util/string/util.h4
-rw-r--r--util/string/util_ut.cpp4
-rw-r--r--util/string/vector.h12
-rw-r--r--util/string/vector_ut.cpp10
-rw-r--r--util/system/atexit.cpp2
-rw-r--r--util/system/atomic_ops.h2
-rw-r--r--util/system/backtrace.cpp8
-rw-r--r--util/system/backtrace.h8
-rw-r--r--util/system/backtrace_ut.cpp2
-rw-r--r--util/system/benchmark/cpu_id/main.cpp100
-rw-r--r--util/system/benchmark/cpu_id/metrics/main.py8
-rw-r--r--util/system/benchmark/cpu_id/metrics/ya.make26
-rw-r--r--util/system/benchmark/cpu_id/ya.make20
-rw-r--r--util/system/benchmark/create_destroy_thread/main.cpp50
-rw-r--r--util/system/benchmark/create_destroy_thread/metrics/main.py8
-rw-r--r--util/system/benchmark/create_destroy_thread/metrics/ya.make26
-rw-r--r--util/system/benchmark/create_destroy_thread/ya.make14
-rw-r--r--util/system/benchmark/ya.make20
-rw-r--r--util/system/compat_ut.cpp4
-rw-r--r--util/system/compiler.h86
-rw-r--r--util/system/compiler_ut.cpp6
-rw-r--r--util/system/condvar.cpp14
-rw-r--r--util/system/condvar.h60
-rw-r--r--util/system/condvar_ut.cpp152
-rw-r--r--util/system/context.cpp6
-rw-r--r--util/system/context_ut.cpp4
-rw-r--r--util/system/cpu_id.cpp222
-rw-r--r--util/system/cpu_id.h10
-rw-r--r--util/system/cpu_id_ut.cpp616
-rw-r--r--util/system/datetime.cpp20
-rw-r--r--util/system/datetime.h14
-rw-r--r--util/system/defaults.h66
-rw-r--r--util/system/direct_io.cpp2
-rw-r--r--util/system/direct_io_ut.cpp4
-rw-r--r--util/system/dynlib.cpp6
-rw-r--r--util/system/dynlib.h4
-rw-r--r--util/system/env.cpp14
-rw-r--r--util/system/env.h44
-rw-r--r--util/system/env_ut.cpp16
-rw-r--r--util/system/error.cpp2
-rw-r--r--util/system/event.cpp2
-rw-r--r--util/system/event_ut.cpp8
-rw-r--r--util/system/execpath.cpp8
-rw-r--r--util/system/execpath_ut.cpp4
-rw-r--r--util/system/fasttime.cpp6
-rw-r--r--util/system/file.cpp14
-rw-r--r--util/system/file_ut.cpp8
-rw-r--r--util/system/filemap.cpp38
-rw-r--r--util/system/filemap.h36
-rw-r--r--util/system/filemap_ut.cpp22
-rw-r--r--util/system/flock_ut.cpp6
-rw-r--r--util/system/fs.cpp8
-rw-r--r--util/system/fs.h26
-rw-r--r--util/system/fs_ut.cpp4
-rw-r--r--util/system/fs_win.cpp16
-rw-r--r--util/system/fs_win.h2
-rw-r--r--util/system/fstat.cpp12
-rw-r--r--util/system/fstat.h12
-rw-r--r--util/system/fstat_ut.cpp152
-rw-r--r--util/system/guard.h12
-rw-r--r--util/system/hostname.cpp2
-rw-r--r--util/system/hp_timer.cpp14
-rw-r--r--util/system/hp_timer.h18
-rw-r--r--util/system/info.cpp2
-rw-r--r--util/system/mem_info.cpp2
-rw-r--r--util/system/mutex.cpp10
-rw-r--r--util/system/nice_ut.cpp6
-rw-r--r--util/system/pipe.cpp2
-rw-r--r--util/system/pipe_ut.cpp4
-rw-r--r--util/system/progname.cpp2
-rw-r--r--util/system/progname_ut.cpp4
-rw-r--r--util/system/rusage_ut.cpp4
-rw-r--r--util/system/rwlock.cpp18
-rw-r--r--util/system/sanitizers_ut.cpp6
-rw-r--r--util/system/sem.cpp14
-rw-r--r--util/system/shellcommand.cpp100
-rw-r--r--util/system/shellcommand.h16
-rw-r--r--util/system/shellcommand_ut.cpp48
-rw-r--r--util/system/shmat.cpp26
-rw-r--r--util/system/shmat_ut.cpp4
-rw-r--r--util/system/sigset.h22
-rw-r--r--util/system/spinlock_ut.cpp6
-rw-r--r--util/system/src_location.cpp2
-rw-r--r--util/system/src_location.h2
-rw-r--r--util/system/src_location_ut.cpp4
-rw-r--r--util/system/src_root.h6
-rw-r--r--util/system/src_root_ut.cpp4
-rw-r--r--util/system/sys_alloc.h8
-rw-r--r--util/system/tempfile_ut.cpp4
-rw-r--r--util/system/thread.cpp60
-rw-r--r--util/system/thread.h26
-rw-r--r--util/system/thread_ut.cpp150
-rw-r--r--util/system/tls.cpp10
-rw-r--r--util/system/tls.h36
-rw-r--r--util/system/tls_ut.cpp6
-rw-r--r--util/system/type_name.cpp2
-rw-r--r--util/system/type_name_ut.cpp4
-rw-r--r--util/system/types_ut.cpp4
-rw-r--r--util/system/unaligned_mem.h84
-rw-r--r--util/system/unaligned_mem_ut.cpp10
-rw-r--r--util/system/user_ut.cpp4
-rw-r--r--util/system/utime.cpp2
-rw-r--r--util/system/yassert.cpp20
-rw-r--r--util/system/yassert.h10
-rw-r--r--util/system/yassert_ut.cpp24
-rw-r--r--util/tests/benchmark/ya.make16
-rw-r--r--util/tests/fuzzing/ya.make8
-rw-r--r--util/thread/factory.cpp2
-rw-r--r--util/thread/fwd.cpp2
-rw-r--r--util/thread/fwd.h42
-rw-r--r--util/thread/lfqueue.h50
-rw-r--r--util/thread/lfqueue_ut.cpp12
-rw-r--r--util/thread/lfstack.h14
-rw-r--r--util/thread/lfstack_ut.cpp16
-rw-r--r--util/thread/pool.cpp18
-rw-r--r--util/thread/pool.h8
-rw-r--r--util/thread/pool_ut.cpp8
-rw-r--r--util/thread/singleton.h4
-rw-r--r--util/thread/singleton_ut.cpp4
-rw-r--r--util/ya.make144
-rw-r--r--util/ysafeptr.cpp6
-rw-r--r--util/ysafeptr.h72
-rw-r--r--util/ysaveload.cpp4
-rw-r--r--util/ysaveload.h142
-rw-r--r--util/ysaveload_ut.cpp6
447 files changed, 7847 insertions, 7847 deletions
diff --git a/util/README.md b/util/README.md
index 2a5429b2eb..496efa633c 100644
--- a/util/README.md
+++ b/util/README.md
@@ -8,11 +8,11 @@ Style guide for the util folder is a stricter version of
* &, * tied closer to a type, not to variable
* always use `using` not `typedef`
* even a single line block must be in braces {}:
- ```
+ ```
if (A) {
B();
}
- ```
+ ```
* _ at the end of private data member of a class - `First_`, `Second_`
* every .h file must be accompanied with corresponding .cpp to avoid a leakage and check that it is self contained
* prohibited to use `printf`-like functions
diff --git a/util/charset/benchmark/to_lower/main.cpp b/util/charset/benchmark/to_lower/main.cpp
index 30260e532d..e95fdc2371 100644
--- a/util/charset/benchmark/to_lower/main.cpp
+++ b/util/charset/benchmark/to_lower/main.cpp
@@ -1,25 +1,25 @@
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/charset/wide.h>
-#include <util/generic/singleton.h>
-#include <util/generic/vector.h>
-#include <util/generic/string.h>
-
-static const auto ShortAscii = UTF8ToWide("hELlo");
-static const auto LongAscii = UTF8ToWide(
- "The first plane, plane 0, the Basic Multilingual Plane (BMP) contains characters for almost "
- "all modern languages, and a large number of symbols. A primary objective for the BMP is to "
- "support the unification of prior character sets as well as characters for writing. Most of "
- "the assigned code points in the BMP are used to encode Chinese, Japanese, and Korean (CJK) "
- "characters.");
-
-static const auto ShortRussian = UTF8ToWide("пРИвет");
-static const auto LongRussian = UTF8ToWide(
- "Плоскость 0 (Основная многоязычная плоскость, англ. Basic Multilingual Plane, BMP) отведена "
- "для символов практически всех современных письменностей и большого числа специальных символов. "
- "Большая часть таблицы занята китайско-японскими иероглифами и своеобразными корейскими"
- "буквами. В Юникоде 10.0 в этой плоскости представлены следующие блоки");
-
+
+#include <util/charset/wide.h>
+#include <util/generic/singleton.h>
+#include <util/generic/vector.h>
+#include <util/generic/string.h>
+
+static const auto ShortAscii = UTF8ToWide("hELlo");
+static const auto LongAscii = UTF8ToWide(
+ "The first plane, plane 0, the Basic Multilingual Plane (BMP) contains characters for almost "
+ "all modern languages, and a large number of symbols. A primary objective for the BMP is to "
+ "support the unification of prior character sets as well as characters for writing. Most of "
+ "the assigned code points in the BMP are used to encode Chinese, Japanese, and Korean (CJK) "
+ "characters.");
+
+static const auto ShortRussian = UTF8ToWide("пРИвет");
+static const auto LongRussian = UTF8ToWide(
+ "Плоскость 0 (Основная многоязычная плоскость, англ. Basic Multilingual Plane, BMP) отведена "
+ "для символов практически всех современных письменностей и большого числа специальных символов. "
+ "Большая часть таблицы занята китайско-японскими иероглифами и своеобразными корейскими"
+ "буквами. В Юникоде 10.0 в этой плоскости представлены следующие блоки");
+
#define DEFINE_INPLACE_BENCH(s) \
Y_CPU_BENCHMARK(s##CopyDetach, iface) { \
for (size_t i = 0, iEnd = iface.Iterations(); i < iEnd; ++i) { \
@@ -38,8 +38,8 @@ static const auto LongRussian = UTF8ToWide(
NBench::Escape(copy.data()); \
NBench::Clobber(); \
} \
- }
-
+ }
+
#define DEFINE_RET_BENCH(s) \
Y_CPU_BENCHMARK(s##Ret, iface) { \
for (size_t i = 0, iEnd = iface.Iterations(); i < iEnd; ++i) { \
@@ -48,14 +48,14 @@ static const auto LongRussian = UTF8ToWide(
NBench::Escape(res.data()); \
NBench::Clobber(); \
} \
- }
-
-DEFINE_INPLACE_BENCH(ShortAscii)
-DEFINE_INPLACE_BENCH(LongAscii)
-DEFINE_INPLACE_BENCH(ShortRussian)
-DEFINE_INPLACE_BENCH(LongRussian)
-
-DEFINE_RET_BENCH(ShortAscii)
-DEFINE_RET_BENCH(LongAscii)
-DEFINE_RET_BENCH(ShortRussian)
-DEFINE_RET_BENCH(LongRussian)
+ }
+
+DEFINE_INPLACE_BENCH(ShortAscii)
+DEFINE_INPLACE_BENCH(LongAscii)
+DEFINE_INPLACE_BENCH(ShortRussian)
+DEFINE_INPLACE_BENCH(LongRussian)
+
+DEFINE_RET_BENCH(ShortAscii)
+DEFINE_RET_BENCH(LongAscii)
+DEFINE_RET_BENCH(ShortRussian)
+DEFINE_RET_BENCH(LongRussian)
diff --git a/util/charset/benchmark/to_lower/metrics/main.py b/util/charset/benchmark/to_lower/metrics/main.py
index d6a4625fa6..e7495d432b 100644
--- a/util/charset/benchmark/to_lower/metrics/main.py
+++ b/util/charset/benchmark/to_lower/metrics/main.py
@@ -1,5 +1,5 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
- metrics.set_benchmark(yc.execute_benchmark('util/charset/benchmark/to_lower/to_lower'))
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
+ metrics.set_benchmark(yc.execute_benchmark('util/charset/benchmark/to_lower/to_lower'))
diff --git a/util/charset/benchmark/to_lower/metrics/ya.make b/util/charset/benchmark/to_lower/metrics/ya.make
index 675cdb7aab..5bb3461a8d 100644
--- a/util/charset/benchmark/to_lower/metrics/ya.make
+++ b/util/charset/benchmark/to_lower/metrics/ya.make
@@ -1,21 +1,21 @@
-OWNER(
- agorodilov
+OWNER(
+ agorodilov
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/charset/benchmark/to_lower)
-
-END()
+
+END()
diff --git a/util/charset/benchmark/to_lower/ya.make b/util/charset/benchmark/to_lower/ya.make
index 2de20e626d..74c47e6de5 100644
--- a/util/charset/benchmark/to_lower/ya.make
+++ b/util/charset/benchmark/to_lower/ya.make
@@ -1,11 +1,11 @@
OWNER(yazevnul)
-
+
Y_BENCHMARK()
-
-ALLOCATOR(B)
-
-SRCS(
- main.cpp
-)
-
-END()
+
+ALLOCATOR(B)
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/charset/benchmark/utf8_to_wide/main.cpp b/util/charset/benchmark/utf8_to_wide/main.cpp
index bdd234bfc6..09fa567fe5 100644
--- a/util/charset/benchmark/utf8_to_wide/main.cpp
+++ b/util/charset/benchmark/utf8_to_wide/main.cpp
@@ -12,7 +12,7 @@ namespace {
template <size_t N>
struct TRandomAsciiString: public TVector<char> {
inline TRandomAsciiString() {
- reserve(N);
+ reserve(N);
for (size_t i = 0; i < N; ++i) {
push_back(RandomNumber<char>(127));
}
diff --git a/util/charset/benchmark/utf8_to_wide/metrics/main.py b/util/charset/benchmark/utf8_to_wide/metrics/main.py
index adadfac791..ffbd8f68fd 100644
--- a/util/charset/benchmark/utf8_to_wide/metrics/main.py
+++ b/util/charset/benchmark/utf8_to_wide/metrics/main.py
@@ -1,5 +1,5 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
- metrics.set_benchmark(yc.execute_benchmark('util/charset/benchmark/utf8_to_wide/utf8_to_wide'))
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
+ metrics.set_benchmark(yc.execute_benchmark('util/charset/benchmark/utf8_to_wide/utf8_to_wide'))
diff --git a/util/charset/benchmark/utf8_to_wide/metrics/ya.make b/util/charset/benchmark/utf8_to_wide/metrics/ya.make
index 997c41fbca..c406e25bee 100644
--- a/util/charset/benchmark/utf8_to_wide/metrics/ya.make
+++ b/util/charset/benchmark/utf8_to_wide/metrics/ya.make
@@ -1,21 +1,21 @@
-OWNER(
- agorodilov
+OWNER(
+ agorodilov
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/charset/benchmark/utf8_to_wide)
-
-END()
+
+END()
diff --git a/util/charset/benchmark/ya.make b/util/charset/benchmark/ya.make
index 9344fc3904..de3e04ef22 100644
--- a/util/charset/benchmark/ya.make
+++ b/util/charset/benchmark/ya.make
@@ -1,12 +1,12 @@
-OWNER(
- agorodilov
+OWNER(
+ agorodilov
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
-RECURSE(
- to_lower
- to_lower/metrics
- utf8_to_wide
- utf8_to_wide/metrics
-)
+
+RECURSE(
+ to_lower
+ to_lower/metrics
+ utf8_to_wide
+ utf8_to_wide/metrics
+)
diff --git a/util/charset/utf8.cpp b/util/charset/utf8.cpp
index a45229c33f..efe3a52f61 100644
--- a/util/charset/utf8.cpp
+++ b/util/charset/utf8.cpp
@@ -93,13 +93,13 @@ static const char* SkipUTF8Chars(const char* begin, const char* end, size_t numC
ythrow yexception() << "invalid UTF-8 char";
}
begin += runeLen;
- Y_ASSERT(begin <= end);
+ Y_ASSERT(begin <= end);
--numChars;
}
return begin;
}
-TStringBuf SubstrUTF8(const TStringBuf str, size_t pos, size_t len) {
+TStringBuf SubstrUTF8(const TStringBuf str, size_t pos, size_t len) {
const char* start = SkipUTF8Chars(str.begin(), str.end(), pos);
const char* end = SkipUTF8Chars(start, str.end(), len);
return TStringBuf(start, end - start);
diff --git a/util/charset/utf8.h b/util/charset/utf8.h
index d64bd3c61d..5039b46ae9 100644
--- a/util/charset/utf8.h
+++ b/util/charset/utf8.h
@@ -11,7 +11,7 @@
extern const wchar32 BROKEN_RUNE;
inline unsigned char UTF8LeadByteMask(size_t utf8_rune_len) {
- // Y_ASSERT (utf8_rune_len <= 4);
+ // Y_ASSERT (utf8_rune_len <= 4);
return "\0\0\037\017\007"[utf8_rune_len];
}
@@ -70,7 +70,7 @@ inline bool IsUTF8ContinuationByte(unsigned char c) {
//! @param p pointer to the current character
//! @param e end of the character sequence
inline RECODE_RESULT GetUTF8CharLen(size_t& n, const unsigned char* p, const unsigned char* e) {
- Y_ASSERT(p < e); // since p < e then we will check RECODE_EOINPUT only for n > 1 (see calls of this functions)
+ Y_ASSERT(p < e); // since p < e then we will check RECODE_EOINPUT only for n > 1 (see calls of this functions)
switch (UTF8RuneLen(*p)) {
case 0:
return RECODE_BROKENSYMBOL; //[BROKENSYMBOL] in first byte
@@ -125,7 +125,7 @@ inline bool GetNumberOfUTF8Chars(const char* text, size_t len, size_t& number) {
break;
}
cur += runeLen;
- Y_ASSERT(cur <= last);
+ Y_ASSERT(cur <= last);
++number;
}
return res;
@@ -195,7 +195,7 @@ inline RECODE_RESULT SafeReadUTF8Char(wchar32& rune, size_t& rune_len, const uns
//! @param p pointer to the current character, it will be changed in case of valid UTF8 byte sequence
//! @param e the end of the character sequence
Y_FORCE_INLINE RECODE_RESULT ReadUTF8CharAndAdvance(wchar32& rune, const unsigned char*& p, const unsigned char* e) noexcept {
- Y_ASSERT(p < e); // since p < e then we will check RECODE_EOINPUT only for n > 1 (see calls of this functions)
+ Y_ASSERT(p < e); // since p < e then we will check RECODE_EOINPUT only for n > 1 (see calls of this functions)
switch (UTF8RuneLen(*p)) {
case 0:
rune = BROKEN_RUNE;
@@ -345,7 +345,7 @@ inline void WriteUTF8Char(wchar32 rune, size_t& rune_len, unsigned char* s) {
}
}
-TStringBuf SubstrUTF8(const TStringBuf str, size_t pos, size_t len);
+TStringBuf SubstrUTF8(const TStringBuf str, size_t pos, size_t len);
enum EUTF8Detect {
NotUTF8,
@@ -355,7 +355,7 @@ enum EUTF8Detect {
EUTF8Detect UTF8Detect(const char* s, size_t len);
-inline EUTF8Detect UTF8Detect(const TStringBuf input) {
+inline EUTF8Detect UTF8Detect(const TStringBuf input) {
return UTF8Detect(input.data(), input.size());
}
@@ -363,7 +363,7 @@ inline bool IsUtf(const char* input, size_t len) {
return UTF8Detect(input, len) != NotUTF8;
}
-inline bool IsUtf(const TStringBuf input) {
+inline bool IsUtf(const TStringBuf input) {
return IsUtf(input.data(), input.size());
}
diff --git a/util/charset/utf8_ut.cpp b/util/charset/utf8_ut.cpp
index 70b7874740..9e68881cca 100644
--- a/util/charset/utf8_ut.cpp
+++ b/util/charset/utf8_ut.cpp
@@ -7,12 +7,12 @@
#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/testing/unittest/env.h>
-Y_UNIT_TEST_SUITE(TUtfUtilTest) {
- Y_UNIT_TEST(TestUTF8Len) {
+Y_UNIT_TEST_SUITE(TUtfUtilTest) {
+ Y_UNIT_TEST(TestUTF8Len) {
UNIT_ASSERT_EQUAL(GetNumberOfUTF8Chars("привет!"), 7);
}
- Y_UNIT_TEST(TestToLowerUtfString) {
+ Y_UNIT_TEST(TestToLowerUtfString) {
UNIT_ASSERT_VALUES_EQUAL(ToLowerUTF8("xyz XYZ ПРИВЕТ!"), "xyz xyz привет!");
UNIT_ASSERT_VALUES_EQUAL(ToLowerUTF8(TStringBuf("xyz")), "xyz");
@@ -92,14 +92,14 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) {
}
}
- Y_UNIT_TEST(TestUTF8ToWide) {
+ Y_UNIT_TEST(TestUTF8ToWide) {
TFileInput in(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/test1.txt"));
TString text = in.ReadAll();
UNIT_ASSERT(WideToUTF8(UTF8ToWide(text)) == text);
}
- Y_UNIT_TEST(TestInvalidUTF8) {
+ Y_UNIT_TEST(TestInvalidUTF8) {
TVector<TString> testData;
TFileInput input(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/invalid_UTF8.bin"));
Load(&input, testData);
@@ -109,7 +109,7 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) {
}
}
- Y_UNIT_TEST(TestUTF8ToWideScalar) {
+ Y_UNIT_TEST(TestUTF8ToWideScalar) {
TFileInput in(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/test1.txt"));
TString text = in.ReadAll();
diff --git a/util/charset/wide.cpp b/util/charset/wide.cpp
index 5c0dc0faed..a287438ddd 100644
--- a/util/charset/wide.cpp
+++ b/util/charset/wide.cpp
@@ -15,16 +15,16 @@ namespace {
inline size_t EscapedLen(wchar16 c) {
switch (c) {
case '<':
- return Y_ARRAY_SIZE(LT);
+ return Y_ARRAY_SIZE(LT);
case '>':
- return Y_ARRAY_SIZE(GT);
+ return Y_ARRAY_SIZE(GT);
case '&':
- return Y_ARRAY_SIZE(AMP);
+ return Y_ARRAY_SIZE(AMP);
case '\"':
- return Y_ARRAY_SIZE(QUOT);
+ return Y_ARRAY_SIZE(QUOT);
default:
if (insertBr && (c == '\r' || c == '\n'))
- return Y_ARRAY_SIZE(BR);
+ return Y_ARRAY_SIZE(BR);
else
return 1;
}
@@ -39,192 +39,192 @@ size_t Collapse(wchar16* s, size_t n) {
return CollapseImpl(s, n, IsWhitespace);
}
-TWtringBuf StripLeft(const TWtringBuf text) noexcept {
- const auto* p = text.data();
- const auto* const pe = text.data() + text.size();
-
- for (; p != pe && IsWhitespace(*p); ++p) {
- }
-
- return {p, pe};
-}
-
-void StripLeft(TUtf16String& text) {
- const auto stripped = StripLeft(TWtringBuf(text));
- if (stripped.size() == text.size()) {
- return;
- }
-
- text = stripped;
-}
-
-TWtringBuf StripRight(const TWtringBuf text) noexcept {
- if (!text) {
- return {};
- }
-
- const auto* const pe = text.data() - 1;
- const auto* p = text.data() + text.size() - 1;
-
- for (; p != pe && IsWhitespace(*p); --p) {
- }
-
- return {pe + 1, p + 1};
-}
-
-void StripRight(TUtf16String& text) {
- const auto stripped = StripRight(TWtringBuf(text));
- if (stripped.size() == text.size()) {
- return;
- }
-
- text.resize(stripped.size());
-}
-
-TWtringBuf Strip(const TWtringBuf text) noexcept {
- return StripRight(StripLeft(text));
-}
-
-void Strip(TUtf16String& text) {
- StripLeft(text);
- StripRight(text);
-}
-
-template <typename T>
-static bool IsReductionOnSymbolsTrue(const TWtringBuf text, T&& f) {
- const auto* p = text.data();
- const auto* const pe = text.data() + text.length();
- while (p != pe) {
- const auto symbol = ReadSymbolAndAdvance(p, pe);
- if (!f(symbol)) {
- return false;
- }
- }
-
- return true;
-}
-
-bool IsLowerWord(const TWtringBuf text) noexcept {
- return IsReductionOnSymbolsTrue(text, [](const wchar32 s) { return IsLower(s); });
-}
-
-bool IsUpperWord(const TWtringBuf text) noexcept {
- return IsReductionOnSymbolsTrue(text, [](const wchar32 s) { return IsUpper(s); });
-}
-
-bool IsLower(const TWtringBuf text) noexcept {
- return IsReductionOnSymbolsTrue(text, [](const wchar32 s) {
- if (IsAlpha(s)) {
- return IsLower(s);
- }
- return true;
- });
-}
-
-bool IsUpper(const TWtringBuf text) noexcept {
- return IsReductionOnSymbolsTrue(text, [](const wchar32 s) {
- if (IsAlpha(s)) {
- return IsUpper(s);
- }
- return true;
- });
-}
-
-bool IsTitleWord(const TWtringBuf text) noexcept {
- if (!text) {
- return false;
- }
-
- const auto* p = text.data();
- const auto* pe = text.data() + text.size();
-
- const auto firstSymbol = ReadSymbolAndAdvance(p, pe);
- if (firstSymbol != ToTitle(firstSymbol)) {
- return false;
- }
-
- return IsLowerWord({p, pe});
-}
-
+TWtringBuf StripLeft(const TWtringBuf text) noexcept {
+ const auto* p = text.data();
+ const auto* const pe = text.data() + text.size();
+
+ for (; p != pe && IsWhitespace(*p); ++p) {
+ }
+
+ return {p, pe};
+}
+
+void StripLeft(TUtf16String& text) {
+ const auto stripped = StripLeft(TWtringBuf(text));
+ if (stripped.size() == text.size()) {
+ return;
+ }
+
+ text = stripped;
+}
+
+TWtringBuf StripRight(const TWtringBuf text) noexcept {
+ if (!text) {
+ return {};
+ }
+
+ const auto* const pe = text.data() - 1;
+ const auto* p = text.data() + text.size() - 1;
+
+ for (; p != pe && IsWhitespace(*p); --p) {
+ }
+
+ return {pe + 1, p + 1};
+}
+
+void StripRight(TUtf16String& text) {
+ const auto stripped = StripRight(TWtringBuf(text));
+ if (stripped.size() == text.size()) {
+ return;
+ }
+
+ text.resize(stripped.size());
+}
+
+TWtringBuf Strip(const TWtringBuf text) noexcept {
+ return StripRight(StripLeft(text));
+}
+
+void Strip(TUtf16String& text) {
+ StripLeft(text);
+ StripRight(text);
+}
+
+template <typename T>
+static bool IsReductionOnSymbolsTrue(const TWtringBuf text, T&& f) {
+ const auto* p = text.data();
+ const auto* const pe = text.data() + text.length();
+ while (p != pe) {
+ const auto symbol = ReadSymbolAndAdvance(p, pe);
+ if (!f(symbol)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool IsLowerWord(const TWtringBuf text) noexcept {
+ return IsReductionOnSymbolsTrue(text, [](const wchar32 s) { return IsLower(s); });
+}
+
+bool IsUpperWord(const TWtringBuf text) noexcept {
+ return IsReductionOnSymbolsTrue(text, [](const wchar32 s) { return IsUpper(s); });
+}
+
+bool IsLower(const TWtringBuf text) noexcept {
+ return IsReductionOnSymbolsTrue(text, [](const wchar32 s) {
+ if (IsAlpha(s)) {
+ return IsLower(s);
+ }
+ return true;
+ });
+}
+
+bool IsUpper(const TWtringBuf text) noexcept {
+ return IsReductionOnSymbolsTrue(text, [](const wchar32 s) {
+ if (IsAlpha(s)) {
+ return IsUpper(s);
+ }
+ return true;
+ });
+}
+
+bool IsTitleWord(const TWtringBuf text) noexcept {
+ if (!text) {
+ return false;
+ }
+
+ const auto* p = text.data();
+ const auto* pe = text.data() + text.size();
+
+ const auto firstSymbol = ReadSymbolAndAdvance(p, pe);
+ if (firstSymbol != ToTitle(firstSymbol)) {
+ return false;
+ }
+
+ return IsLowerWord({p, pe});
+}
+
template <bool stopOnFirstModification, typename TCharType, typename F>
static bool ModifySequence(TCharType*& p, const TCharType* const pe, F&& f) {
- while (p != pe) {
- const auto symbol = ReadSymbol(p, pe);
- const auto modified = f(symbol);
- if (symbol != modified) {
- if (stopOnFirstModification) {
- return true;
- }
-
+ while (p != pe) {
+ const auto symbol = ReadSymbol(p, pe);
+ const auto modified = f(symbol);
+ if (symbol != modified) {
+ if (stopOnFirstModification) {
+ return true;
+ }
+
WriteSymbol(modified, p); // also moves `p` forward
- } else {
- p = SkipSymbol(p, pe);
- }
- }
-
- return false;
-}
-
+ } else {
+ p = SkipSymbol(p, pe);
+ }
+ }
+
+ return false;
+}
+
template <bool stopOnFirstModification, typename TCharType, typename F>
static bool ModifySequence(const TCharType*& p, const TCharType* const pe, TCharType*& out, F&& f) {
- while (p != pe) {
- const auto symbol = stopOnFirstModification ? ReadSymbol(p, pe) : ReadSymbolAndAdvance(p, pe);
- const auto modified = f(symbol);
-
- if (stopOnFirstModification) {
- if (symbol != modified) {
- return true;
- }
-
- p = SkipSymbol(p, pe);
- }
-
- WriteSymbol(modified, out);
- }
-
- return false;
-}
-
+ while (p != pe) {
+ const auto symbol = stopOnFirstModification ? ReadSymbol(p, pe) : ReadSymbolAndAdvance(p, pe);
+ const auto modified = f(symbol);
+
+ if (stopOnFirstModification) {
+ if (symbol != modified) {
+ return true;
+ }
+
+ p = SkipSymbol(p, pe);
+ }
+
+ WriteSymbol(modified, out);
+ }
+
+ return false;
+}
+
template <class TStringType>
static void DetachAndFixPointers(TStringType& text, typename TStringType::value_type*& p, const typename TStringType::value_type*& pe) {
- const auto pos = p - text.data();
- const auto count = pe - p;
- p = text.Detach() + pos;
- pe = p + count;
-}
-
+ const auto pos = p - text.data();
+ const auto count = pe - p;
+ p = text.Detach() + pos;
+ pe = p + count;
+}
+
template <class TStringType, typename F>
static bool ModifyStringSymbolwise(TStringType& text, size_t pos, size_t count, F&& f) {
- // TODO(yazevnul): this is done for consistency with `TUtf16String::to_lower` and friends
- // at r2914050, maybe worth replacing them with asserts. Also see the same code in `ToTitle`.
- pos = pos < text.size() ? pos : text.size();
- count = count < text.size() - pos ? count : text.size() - pos;
-
- // TUtf16String is refcounted and it's `data` method return pointer to the constant memory.
- // To simplify the code we do a `const_cast`, though first write to the memory will be done only
- // after we call `Detach()` and get pointer to a writable piece of memory.
+ // TODO(yazevnul): this is done for consistency with `TUtf16String::to_lower` and friends
+ // at r2914050, maybe worth replacing them with asserts. Also see the same code in `ToTitle`.
+ pos = pos < text.size() ? pos : text.size();
+ count = count < text.size() - pos ? count : text.size() - pos;
+
+ // TUtf16String is refcounted and it's `data` method return pointer to the constant memory.
+ // To simplify the code we do a `const_cast`, though first write to the memory will be done only
+ // after we call `Detach()` and get pointer to a writable piece of memory.
auto* p = const_cast<typename TStringType::value_type*>(text.data() + pos);
- const auto* pe = text.data() + pos + count;
-
- if (ModifySequence<true>(p, pe, f)) {
- DetachAndFixPointers(text, p, pe);
- ModifySequence<false>(p, pe, f);
- return true;
- }
-
- return false;
-}
-
-bool ToLower(TUtf16String& text, size_t pos, size_t count) {
- const auto f = [](const wchar32 s) { return ToLower(s); };
- return ModifyStringSymbolwise(text, pos, count, f);
-}
-
-bool ToUpper(TUtf16String& text, size_t pos, size_t count) {
- const auto f = [](const wchar32 s) { return ToUpper(s); };
- return ModifyStringSymbolwise(text, pos, count, f);
-}
-
+ const auto* pe = text.data() + pos + count;
+
+ if (ModifySequence<true>(p, pe, f)) {
+ DetachAndFixPointers(text, p, pe);
+ ModifySequence<false>(p, pe, f);
+ return true;
+ }
+
+ return false;
+}
+
+bool ToLower(TUtf16String& text, size_t pos, size_t count) {
+ const auto f = [](const wchar32 s) { return ToLower(s); };
+ return ModifyStringSymbolwise(text, pos, count, f);
+}
+
+bool ToUpper(TUtf16String& text, size_t pos, size_t count) {
+ const auto f = [](const wchar32 s) { return ToUpper(s); };
+ return ModifyStringSymbolwise(text, pos, count, f);
+}
+
bool ToLower(TUtf32String& text, size_t pos, size_t count) {
const auto f = [](const wchar32 s) { return ToLower(s); };
return ModifyStringSymbolwise(text, pos, count, f);
@@ -235,37 +235,37 @@ bool ToUpper(TUtf32String& text, size_t pos, size_t count) {
return ModifyStringSymbolwise(text, pos, count, f);
}
-bool ToTitle(TUtf16String& text, size_t pos, size_t count) {
- if (!text) {
- return false;
- }
-
- pos = pos < text.size() ? pos : text.size();
- count = count < text.size() - pos ? count : text.size() - pos;
-
- const auto toLower = [](const wchar32 s) { return ToLower(s); };
-
- auto* p = const_cast<wchar16*>(text.data() + pos);
- const auto* pe = text.data() + pos + count;
-
- const auto firstSymbol = ReadSymbol(p, pe);
- if (firstSymbol == ToTitle(firstSymbol)) {
- p = SkipSymbol(p, pe);
- if (ModifySequence<true>(p, pe, toLower)) {
- DetachAndFixPointers(text, p, pe);
- ModifySequence<false>(p, pe, toLower);
- return true;
- }
- } else {
- DetachAndFixPointers(text, p, pe);
+bool ToTitle(TUtf16String& text, size_t pos, size_t count) {
+ if (!text) {
+ return false;
+ }
+
+ pos = pos < text.size() ? pos : text.size();
+ count = count < text.size() - pos ? count : text.size() - pos;
+
+ const auto toLower = [](const wchar32 s) { return ToLower(s); };
+
+ auto* p = const_cast<wchar16*>(text.data() + pos);
+ const auto* pe = text.data() + pos + count;
+
+ const auto firstSymbol = ReadSymbol(p, pe);
+ if (firstSymbol == ToTitle(firstSymbol)) {
+ p = SkipSymbol(p, pe);
+ if (ModifySequence<true>(p, pe, toLower)) {
+ DetachAndFixPointers(text, p, pe);
+ ModifySequence<false>(p, pe, toLower);
+ return true;
+ }
+ } else {
+ DetachAndFixPointers(text, p, pe);
WriteSymbol(ToTitle(ReadSymbol(p, pe)), p); // also moves `p` forward
- ModifySequence<false>(p, pe, toLower);
- return true;
- }
-
- return false;
-}
-
+ ModifySequence<false>(p, pe, toLower);
+ return true;
+ }
+
+ return false;
+}
+
bool ToTitle(TUtf32String& text, size_t pos, size_t count) {
if (!text) {
return false;
@@ -297,21 +297,21 @@ bool ToTitle(TUtf32String& text, size_t pos, size_t count) {
return false;
}
-TUtf16String ToLowerRet(TUtf16String text, size_t pos, size_t count) {
- ToLower(text, pos, count);
- return text;
-}
-
-TUtf16String ToUpperRet(TUtf16String text, size_t pos, size_t count) {
- ToUpper(text, pos, count);
- return text;
-}
-
-TUtf16String ToTitleRet(TUtf16String text, size_t pos, size_t count) {
- ToTitle(text, pos, count);
- return text;
-}
-
+TUtf16String ToLowerRet(TUtf16String text, size_t pos, size_t count) {
+ ToLower(text, pos, count);
+ return text;
+}
+
+TUtf16String ToUpperRet(TUtf16String text, size_t pos, size_t count) {
+ ToUpper(text, pos, count);
+ return text;
+}
+
+TUtf16String ToTitleRet(TUtf16String text, size_t pos, size_t count) {
+ ToTitle(text, pos, count);
+ return text;
+}
+
TUtf32String ToLowerRet(TUtf32String text, size_t pos, size_t count) {
ToLower(text, pos, count);
return text;
@@ -327,87 +327,87 @@ TUtf32String ToTitleRet(TUtf32String text, size_t pos, size_t count) {
return text;
}
-bool ToLower(const wchar16* text, size_t length, wchar16* out) noexcept {
- // TODO(yazevnul): get rid of `text == out` case (it is probably used only in lemmer) and then
- // we can declare text and out as `__restrict__`
- Y_ASSERT(text == out || !(out >= text && out < text + length));
- const auto f = [](const wchar32 s) { return ToLower(s); };
- const auto* p = text;
- const auto* const pe = text + length;
- if (ModifySequence<true>(p, pe, out, f)) {
- ModifySequence<false>(p, pe, out, f);
- return true;
- }
- return false;
-}
-
-bool ToUpper(const wchar16* text, size_t length, wchar16* out) noexcept {
- Y_ASSERT(text == out || !(out >= text && out < text + length));
- const auto f = [](const wchar32 s) { return ToUpper(s); };
- const auto* p = text;
- const auto* const pe = text + length;
- if (ModifySequence<true>(p, pe, out, f)) {
- ModifySequence<false>(p, pe, out, f);
- return true;
- }
- return false;
-}
-
-bool ToTitle(const wchar16* text, size_t length, wchar16* out) noexcept {
- if (!length) {
- return false;
- }
-
- Y_ASSERT(text == out || !(out >= text && out < text + length));
-
- const auto* const textEnd = text + length;
- const auto firstSymbol = ReadSymbolAndAdvance(text, textEnd);
- const auto firstSymbolTitle = ToTitle(firstSymbol);
-
- WriteSymbol(firstSymbolTitle, out);
-
- return ToLower(text, textEnd - text, out) || firstSymbol != firstSymbolTitle;
-}
-
-bool ToLower(wchar16* text, size_t length) noexcept {
- const auto f = [](const wchar32 s) { return ToLower(s); };
- const auto* const textEnd = text + length;
- if (ModifySequence<true>(text, textEnd, f)) {
- ModifySequence<false>(text, textEnd, f);
- return true;
- }
- return false;
-}
-
-bool ToUpper(wchar16* text, size_t length) noexcept {
- const auto f = [](const wchar32 s) { return ToUpper(s); };
- const auto* const textEnd = text + length;
- if (ModifySequence<true>(text, textEnd, f)) {
- ModifySequence<false>(text, textEnd, f);
- return true;
- }
- return false;
-}
-
-bool ToTitle(wchar16* text, size_t length) noexcept {
- if (!length) {
- return false;
- }
-
- const auto* textEnd = text + length;
- const auto firstSymbol = ReadSymbol(text, textEnd);
- const auto firstSymbolTitle = ToTitle(firstSymbol);
-
- // avoid unnacessary writes to the memory
- if (firstSymbol != firstSymbolTitle) {
- WriteSymbol(firstSymbolTitle, text);
- } else {
- text = SkipSymbol(text, textEnd);
- }
-
- return ToLower(text, textEnd - text) || firstSymbol != firstSymbolTitle;
-}
-
+bool ToLower(const wchar16* text, size_t length, wchar16* out) noexcept {
+ // TODO(yazevnul): get rid of `text == out` case (it is probably used only in lemmer) and then
+ // we can declare text and out as `__restrict__`
+ Y_ASSERT(text == out || !(out >= text && out < text + length));
+ const auto f = [](const wchar32 s) { return ToLower(s); };
+ const auto* p = text;
+ const auto* const pe = text + length;
+ if (ModifySequence<true>(p, pe, out, f)) {
+ ModifySequence<false>(p, pe, out, f);
+ return true;
+ }
+ return false;
+}
+
+bool ToUpper(const wchar16* text, size_t length, wchar16* out) noexcept {
+ Y_ASSERT(text == out || !(out >= text && out < text + length));
+ const auto f = [](const wchar32 s) { return ToUpper(s); };
+ const auto* p = text;
+ const auto* const pe = text + length;
+ if (ModifySequence<true>(p, pe, out, f)) {
+ ModifySequence<false>(p, pe, out, f);
+ return true;
+ }
+ return false;
+}
+
+bool ToTitle(const wchar16* text, size_t length, wchar16* out) noexcept {
+ if (!length) {
+ return false;
+ }
+
+ Y_ASSERT(text == out || !(out >= text && out < text + length));
+
+ const auto* const textEnd = text + length;
+ const auto firstSymbol = ReadSymbolAndAdvance(text, textEnd);
+ const auto firstSymbolTitle = ToTitle(firstSymbol);
+
+ WriteSymbol(firstSymbolTitle, out);
+
+ return ToLower(text, textEnd - text, out) || firstSymbol != firstSymbolTitle;
+}
+
+bool ToLower(wchar16* text, size_t length) noexcept {
+ const auto f = [](const wchar32 s) { return ToLower(s); };
+ const auto* const textEnd = text + length;
+ if (ModifySequence<true>(text, textEnd, f)) {
+ ModifySequence<false>(text, textEnd, f);
+ return true;
+ }
+ return false;
+}
+
+bool ToUpper(wchar16* text, size_t length) noexcept {
+ const auto f = [](const wchar32 s) { return ToUpper(s); };
+ const auto* const textEnd = text + length;
+ if (ModifySequence<true>(text, textEnd, f)) {
+ ModifySequence<false>(text, textEnd, f);
+ return true;
+ }
+ return false;
+}
+
+bool ToTitle(wchar16* text, size_t length) noexcept {
+ if (!length) {
+ return false;
+ }
+
+ const auto* textEnd = text + length;
+ const auto firstSymbol = ReadSymbol(text, textEnd);
+ const auto firstSymbolTitle = ToTitle(firstSymbol);
+
+ // avoid unnacessary writes to the memory
+ if (firstSymbol != firstSymbolTitle) {
+ WriteSymbol(firstSymbolTitle, text);
+ } else {
+ text = SkipSymbol(text, textEnd);
+ }
+
+ return ToLower(text, textEnd - text) || firstSymbol != firstSymbolTitle;
+}
+
bool ToLower(const wchar32* text, size_t length, wchar32* out) noexcept {
// TODO(yazevnul): get rid of `text == out` case (it is probably used only in lemmer) and then
// we can declare text and out as `__restrict__`
@@ -489,27 +489,27 @@ bool ToTitle(wchar32* text, size_t length) noexcept {
return ToLower(text, textEnd - text) || firstSymbol != firstSymbolTitle;
}
-template <typename F>
-static TUtf16String ToSmthRet(const TWtringBuf text, size_t pos, size_t count, F&& f) {
- pos = pos < text.size() ? pos : text.size();
- count = count < text.size() - pos ? count : text.size() - pos;
-
- auto res = TUtf16String::Uninitialized(text.size());
- auto* const resBegin = res.Detach();
-
- if (pos) {
- MemCopy(resBegin, text.data(), pos);
- }
-
- f(text.data() + pos, count, resBegin + pos);
-
- if (count - pos != text.size()) {
- MemCopy(resBegin + pos + count, text.data() + pos + count, text.size() - pos - count);
- }
-
- return res;
-}
-
+template <typename F>
+static TUtf16String ToSmthRet(const TWtringBuf text, size_t pos, size_t count, F&& f) {
+ pos = pos < text.size() ? pos : text.size();
+ count = count < text.size() - pos ? count : text.size() - pos;
+
+ auto res = TUtf16String::Uninitialized(text.size());
+ auto* const resBegin = res.Detach();
+
+ if (pos) {
+ MemCopy(resBegin, text.data(), pos);
+ }
+
+ f(text.data() + pos, count, resBegin + pos);
+
+ if (count - pos != text.size()) {
+ MemCopy(resBegin + pos + count, text.data() + pos + count, text.size() - pos - count);
+ }
+
+ return res;
+}
+
template <typename F>
static TUtf32String ToSmthRet(const TUtf32StringBuf text, size_t pos, size_t count, F&& f) {
pos = pos < text.size() ? pos : text.size();
@@ -531,24 +531,24 @@ static TUtf32String ToSmthRet(const TUtf32StringBuf text, size_t pos, size_t cou
return res;
}
-TUtf16String ToLowerRet(const TWtringBuf text, size_t pos, size_t count) {
+TUtf16String ToLowerRet(const TWtringBuf text, size_t pos, size_t count) {
return ToSmthRet(text, pos, count, [](const wchar16* theText, size_t length, wchar16* out) {
ToLower(theText, length, out);
- });
-}
-
-TUtf16String ToUpperRet(const TWtringBuf text, size_t pos, size_t count) {
+ });
+}
+
+TUtf16String ToUpperRet(const TWtringBuf text, size_t pos, size_t count) {
return ToSmthRet(text, pos, count, [](const wchar16* theText, size_t length, wchar16* out) {
ToUpper(theText, length, out);
- });
-}
-
-TUtf16String ToTitleRet(const TWtringBuf text, size_t pos, size_t count) {
+ });
+}
+
+TUtf16String ToTitleRet(const TWtringBuf text, size_t pos, size_t count) {
return ToSmthRet(text, pos, count, [](const wchar16* theText, size_t length, wchar16* out) {
ToTitle(theText, length, out);
- });
-}
-
+ });
+}
+
TUtf32String ToLowerRet(const TUtf32StringBuf text, size_t pos, size_t count) {
return ToSmthRet(text, pos, count, [](const wchar32* theText, size_t length, wchar32* out) {
ToLower(theText, length, out);
diff --git a/util/charset/wide.h b/util/charset/wide.h
index 81e7282f90..04e6928aab 100644
--- a/util/charset/wide.h
+++ b/util/charset/wide.h
@@ -5,12 +5,12 @@
#include "utf8.h"
#include "wide_specific.h"
-#include <util/generic/algorithm.h>
+#include <util/generic/algorithm.h>
#include <util/generic/string.h>
#include <util/generic/yexception.h>
#include <util/memory/tempbuf.h>
-#include <util/system/compiler.h>
-#include <util/system/cpu_id.h>
+#include <util/system/compiler.h>
+#include <util/system/cpu_id.h>
#include <util/system/yassert.h>
#include <cstring>
@@ -79,7 +79,7 @@ inline const wchar32* SkipSymbol(const wchar32* begin, const wchar32* end) noexc
}
inline wchar32 ReadSymbol(const wchar16* begin, const wchar16* end) noexcept {
- Y_ASSERT(begin < end);
+ Y_ASSERT(begin < end);
if (IsW16SurrogateLead(*begin)) {
if (begin + 1 < end && IsW16SurrogateTail(*(begin + 1)))
return ::NDetail::ReadSurrogatePair(begin);
@@ -99,10 +99,10 @@ inline wchar32 ReadSymbol(const wchar32* begin, const wchar32* end) noexcept {
//! presuming input data is either big enought of null terminated
inline wchar32 ReadSymbolAndAdvance(const wchar16*& begin) noexcept {
- Y_ASSERT(*begin);
+ Y_ASSERT(*begin);
if (IsW16SurrogateLead(begin[0])) {
if (IsW16SurrogateTail(begin[1])) {
- Y_ASSERT(begin[1] != 0);
+ Y_ASSERT(begin[1] != 0);
const wchar32 c = ::NDetail::ReadSurrogatePair(begin);
begin += 2;
return c;
@@ -123,7 +123,7 @@ inline wchar32 ReadSymbolAndAdvance(const wchar32*& begin) noexcept {
}
inline wchar32 ReadSymbolAndAdvance(const wchar16*& begin, const wchar16* end) noexcept {
- Y_ASSERT(begin < end);
+ Y_ASSERT(begin < end);
if (IsW16SurrogateLead(begin[0])) {
if (begin + 1 != end && IsW16SurrogateTail(begin[1])) {
const wchar32 c = ::NDetail::ReadSurrogatePair(begin);
@@ -140,7 +140,7 @@ inline wchar32 ReadSymbolAndAdvance(const wchar16*& begin, const wchar16* end) n
}
inline wchar32 ReadSymbolAndAdvance(const wchar32*& begin, const wchar32* end) noexcept {
- Y_ASSERT(begin < end);
+ Y_ASSERT(begin < end);
return *(begin++);
}
@@ -165,7 +165,7 @@ inline size_t WriteSymbol(wchar32 s, T& dest) noexcept {
}
inline bool WriteSymbol(wchar32 s, wchar16*& dest, const wchar16* destEnd) noexcept {
- Y_ASSERT(dest < destEnd);
+ Y_ASSERT(dest < destEnd);
if (s > 0xFFFF) {
if (s >= NUnicode::UnicodeInstancesLimit()) {
@@ -190,7 +190,7 @@ inline size_t WriteSymbol(wchar32 s, wchar32*& dest) noexcept {
}
inline bool WriteSymbol(wchar32 s, wchar32*& dest, const wchar32* destEnd) noexcept {
- Y_ASSERT(dest < destEnd);
+ Y_ASSERT(dest < destEnd);
*(dest++) = s;
@@ -200,7 +200,7 @@ inline bool WriteSymbol(wchar32 s, wchar32*& dest, const wchar32* destEnd) noexc
template <class T>
inline void ::NDetail::WriteSurrogatePair(wchar32 s, T& dest) noexcept {
const wchar32 LEAD_OFFSET = 0xD800 - (0x10000 >> 10);
- Y_ASSERT(s > 0xFFFF && s < ::NUnicode::UnicodeInstancesLimit());
+ Y_ASSERT(s > 0xFFFF && s < ::NUnicode::UnicodeInstancesLimit());
wchar16 lead = LEAD_OFFSET + (static_cast<wchar16>(s >> 10));
wchar16 tail = 0xDC00 + static_cast<wchar16>(s & 0x3FF);
@@ -327,7 +327,7 @@ inline TUtf16String UTF8ToWide(const char* text, size_t len) {
size_t pos = UTF8ToWideImpl<robust>(text, len, w.begin(), written);
if (pos != len)
ythrow yexception() << "failed to decode UTF-8 string at pos " << pos << ::NDetail::InStringMsg(text, len);
- Y_ASSERT(w.size() >= written);
+ Y_ASSERT(w.size() >= written);
w.remove(written);
return w;
}
@@ -400,7 +400,7 @@ inline void WideToUTF8(const TCharType* text, size_t len, char* dest, size_t& wr
size_t runeLen;
for (const TCharType* cur = text; cur != last;) {
WriteUTF8Char(ReadSymbolAndAdvance(cur, last), runeLen, p);
- Y_ASSERT(runeLen <= 4);
+ Y_ASSERT(runeLen <= 4);
p += runeLen;
}
written = p - reinterpret_cast<unsigned char*>(dest);
@@ -414,7 +414,7 @@ inline TStringBuf WideToUTF8(const TWtringBuf src, TString& dst) {
dst.ReserveAndResize(WideToUTF8BufferSize(src.size()));
size_t written = 0;
WideToUTF8(src.data(), src.size(), dst.begin(), written);
- Y_ASSERT(dst.size() >= written);
+ Y_ASSERT(dst.size() >= written);
dst.remove(written);
return dst;
}
@@ -423,7 +423,7 @@ inline TString WideToUTF8(const wchar16* text, size_t len) {
TString s = TString::Uninitialized(WideToUTF8BufferSize(len));
size_t written = 0;
WideToUTF8(text, len, s.begin(), written);
- Y_ASSERT(s.size() >= written);
+ Y_ASSERT(s.size() >= written);
s.remove(written);
return s;
}
@@ -469,49 +469,49 @@ namespace NDetail {
return !(reinterpret_cast<TMachineWord>(pointer) & kMachineWordAlignmentMask);
}
- template <typename T>
+ template <typename T>
inline T* AlignToMachineWord(T* pointer) {
return reinterpret_cast<T*>(reinterpret_cast<TMachineWord>(pointer) & ~kMachineWordAlignmentMask);
}
- template <size_t size, typename CharacterType>
+ template <size_t size, typename CharacterType>
struct NonASCIIMask;
- template <>
- struct
- NonASCIIMask<4, wchar16> {
- static constexpr ui32 Value() {
- return 0xFF80FF80U;
- }
+ template <>
+ struct
+ NonASCIIMask<4, wchar16> {
+ static constexpr ui32 Value() {
+ return 0xFF80FF80U;
+ }
};
- template <>
- struct
- NonASCIIMask<4, char> {
- static constexpr ui32 Value() {
- return 0x80808080U;
- }
+ template <>
+ struct
+ NonASCIIMask<4, char> {
+ static constexpr ui32 Value() {
+ return 0x80808080U;
+ }
};
- template <>
- struct
- NonASCIIMask<8, wchar16> {
- static constexpr ui64 Value() {
- return 0xFF80FF80FF80FF80ULL;
- }
+ template <>
+ struct
+ NonASCIIMask<8, wchar16> {
+ static constexpr ui64 Value() {
+ return 0xFF80FF80FF80FF80ULL;
+ }
};
- template <>
- struct
- NonASCIIMask<8, char> {
- static constexpr ui64 Value() {
- return 0x8080808080808080ULL;
- }
+ template <>
+ struct
+ NonASCIIMask<8, char> {
+ static constexpr ui64 Value() {
+ return 0x8080808080808080ULL;
+ }
};
template <typename TChar>
inline bool DoIsStringASCIISlow(const TChar* first, const TChar* last) {
- using TUnsignedChar = std::make_unsigned_t<TChar>;
+ using TUnsignedChar = std::make_unsigned_t<TChar>;
Y_ASSERT(first <= last);
for (; first != last; ++first) {
if (static_cast<TUnsignedChar>(*first) > 0x7F) {
@@ -573,7 +573,7 @@ namespace NDetail {
int asciiMask = _mm_movemask_epi8(chunk);
if (asciiMask) {
return false;
- }
+ }
first += 16;
}
@@ -630,7 +630,7 @@ inline void Copy(const TChar1* first, size_t len, TChar2* result) {
//! and the family of template member functions: append, assign, insert, replace.
template <typename TStringType, typename TChar>
inline TStringType CopyTo(const TChar* first, const TChar* last) {
- Y_ASSERT(first <= last);
+ Y_ASSERT(first <= last);
TStringType str = TStringType::Uninitialized(last - first);
Copy(first, last, str.begin());
return str;
@@ -644,12 +644,12 @@ inline TStringType CopyTo(const TChar* s, size_t n) {
}
inline TString WideToASCII(const TWtringBuf w) {
- Y_ASSERT(IsStringASCII(w.begin(), w.end()));
+ Y_ASSERT(IsStringASCII(w.begin(), w.end()));
return CopyTo<TString>(w.begin(), w.end());
}
inline TUtf16String ASCIIToWide(const TStringBuf s) {
- Y_ASSERT(IsStringASCII(s.begin(), s.end()));
+ Y_ASSERT(IsStringASCII(s.begin(), s.end()));
return CopyTo<TUtf16String>(s.begin(), s.end());
}
@@ -663,7 +663,7 @@ inline bool IsSpace(const wchar16* s, size_t n) {
if (n == 0)
return false;
- Y_ASSERT(s);
+ Y_ASSERT(s);
const wchar16* const e = s + n;
for (const wchar16* p = s; p != e; ++p) {
@@ -674,7 +674,7 @@ inline bool IsSpace(const wchar16* s, size_t n) {
}
//! returns @c true if string contains whitespace characters only
-inline bool IsSpace(const TWtringBuf s) {
+inline bool IsSpace(const TWtringBuf s) {
return IsSpace(s.data(), s.length());
}
@@ -684,61 +684,61 @@ void Collapse(TUtf16String& w);
//! @return new length
size_t Collapse(wchar16* s, size_t n);
-//! Removes leading whitespace characters
-TWtringBuf StripLeft(const TWtringBuf text) noexcept Y_WARN_UNUSED_RESULT;
-void StripLeft(TUtf16String& text);
-
-//! Removes trailing whitespace characters
-TWtringBuf StripRight(const TWtringBuf text) noexcept Y_WARN_UNUSED_RESULT;
-void StripRight(TUtf16String& text);
-
-//! Removes leading and trailing whitespace characters
-TWtringBuf Strip(const TWtringBuf text) noexcept Y_WARN_UNUSED_RESULT;
-void Strip(TUtf16String& text);
-
-/* Check if given word is lowercase/uppercase. Will return false if string contains any
- * non-alphabetical symbols. It is expected that `text` is a correct UTF-16 string.
- *
- * For example `IsLowerWord("hello")` will return `true`, when `IsLowerWord("hello there")` will
- * return false because of the space in the middle of the string. Empty string is also considered
- * lowercase.
- */
-bool IsLowerWord(const TWtringBuf text) noexcept;
-bool IsUpperWord(const TWtringBuf text) noexcept;
-
-/* Will check if given word starts with capital letter and the rest of the word is lowercase. Will
- * return `false` for empty string. See also `IsLowerWord`.
- */
-bool IsTitleWord(const TWtringBuf text) noexcept;
-
-/* Check if given string is lowercase/uppercase. Will return `true` if all alphabetic symbols are
- * in proper case, all other symbols are ignored. It is expected that `text` is a correct UTF-16
- * string.
- *
- * For example `IsLowerWord("hello")` will return `true` and `IsLowerWord("hello there")` will
- * also return true because. Empty string is also considered lowercase.
- *
- * NOTE: for any case where `IsLowerWord` returns `true` `IsLower` will also return `true`.
- */
-bool IsLower(const TWtringBuf text) noexcept;
-bool IsUpper(const TWtringBuf text) noexcept;
-
-/* Lowercase/uppercase given string inplace. Any alphabetic symbol will be converted to a proper
- * case, the rest of the symbols will be kept the same. It is expected that `text` is a correct
- * UTF-16 string.
- *
- * For example `ToLower("heLLo")` will return `"hello"`.
- *
- * @param text String to modify
- * @param pos Position of the first character to modify
- * @param count Length of the substring
- * @returns `true` if `text` was changed
- *
- * NOTE: `pos` and `count` are measured in `wchar16`, not in codepoints.
- */
-bool ToLower(TUtf16String& text, size_t pos = 0, size_t count = TUtf16String::npos);
-bool ToUpper(TUtf16String& text, size_t pos = 0, size_t count = TUtf16String::npos);
-
+//! Removes leading whitespace characters
+TWtringBuf StripLeft(const TWtringBuf text) noexcept Y_WARN_UNUSED_RESULT;
+void StripLeft(TUtf16String& text);
+
+//! Removes trailing whitespace characters
+TWtringBuf StripRight(const TWtringBuf text) noexcept Y_WARN_UNUSED_RESULT;
+void StripRight(TUtf16String& text);
+
+//! Removes leading and trailing whitespace characters
+TWtringBuf Strip(const TWtringBuf text) noexcept Y_WARN_UNUSED_RESULT;
+void Strip(TUtf16String& text);
+
+/* Check if given word is lowercase/uppercase. Will return false if string contains any
+ * non-alphabetical symbols. It is expected that `text` is a correct UTF-16 string.
+ *
+ * For example `IsLowerWord("hello")` will return `true`, when `IsLowerWord("hello there")` will
+ * return false because of the space in the middle of the string. Empty string is also considered
+ * lowercase.
+ */
+bool IsLowerWord(const TWtringBuf text) noexcept;
+bool IsUpperWord(const TWtringBuf text) noexcept;
+
+/* Will check if given word starts with capital letter and the rest of the word is lowercase. Will
+ * return `false` for empty string. See also `IsLowerWord`.
+ */
+bool IsTitleWord(const TWtringBuf text) noexcept;
+
+/* Check if given string is lowercase/uppercase. Will return `true` if all alphabetic symbols are
+ * in proper case, all other symbols are ignored. It is expected that `text` is a correct UTF-16
+ * string.
+ *
+ * For example `IsLowerWord("hello")` will return `true` and `IsLowerWord("hello there")` will
+ * also return true because. Empty string is also considered lowercase.
+ *
+ * NOTE: for any case where `IsLowerWord` returns `true` `IsLower` will also return `true`.
+ */
+bool IsLower(const TWtringBuf text) noexcept;
+bool IsUpper(const TWtringBuf text) noexcept;
+
+/* Lowercase/uppercase given string inplace. Any alphabetic symbol will be converted to a proper
+ * case, the rest of the symbols will be kept the same. It is expected that `text` is a correct
+ * UTF-16 string.
+ *
+ * For example `ToLower("heLLo")` will return `"hello"`.
+ *
+ * @param text String to modify
+ * @param pos Position of the first character to modify
+ * @param count Length of the substring
+ * @returns `true` if `text` was changed
+ *
+ * NOTE: `pos` and `count` are measured in `wchar16`, not in codepoints.
+ */
+bool ToLower(TUtf16String& text, size_t pos = 0, size_t count = TUtf16String::npos);
+bool ToUpper(TUtf16String& text, size_t pos = 0, size_t count = TUtf16String::npos);
+
/* Lowercase/uppercase given string inplace. Any alphabetic symbol will be converted to a proper
* case, the rest of the symbols will be kept the same. It is expected that `text` is a correct
* UTF-32 string.
@@ -755,54 +755,54 @@ bool ToUpper(TUtf16String& text, size_t pos = 0, size_t count = TUtf16String::np
bool ToLower(TUtf32String& /*text*/, size_t /*pos*/ = 0, size_t /*count*/ = TUtf16String::npos);
bool ToUpper(TUtf32String& /*text*/, size_t /*pos*/ = 0, size_t /*count*/ = TUtf16String::npos);
-/* Titlecase first symbol and lowercase the rest, see `ToLower` for more details.
- */
-bool ToTitle(TUtf16String& text, size_t pos = 0, size_t count = TUtf16String::npos);
-
+/* Titlecase first symbol and lowercase the rest, see `ToLower` for more details.
+ */
+bool ToTitle(TUtf16String& text, size_t pos = 0, size_t count = TUtf16String::npos);
+
/* Titlecase first symbol and lowercase the rest, see `ToLower` for more details.
*/
bool ToTitle(TUtf32String& /*text*/, size_t /*pos*/ = 0, size_t /*count*/ = TUtf16String::npos);
-/* @param text Pointer to the string to modify
- * @param length Length of the string to modify
- * @param out Pointer to the character array to write to
- *
- * NOTE: [text, text+length) and [out, out+length) should not interleave.
- *
- * TODO(yazevnul): replace these functions with `bool(const TWtringBuf, const TArrayRef<wchar16>)`
- * overload.
- */
-bool ToLower(const wchar16* text, size_t length, wchar16* out) noexcept;
-bool ToUpper(const wchar16* text, size_t length, wchar16* out) noexcept;
-bool ToTitle(const wchar16* text, size_t length, wchar16* out) noexcept;
-
+/* @param text Pointer to the string to modify
+ * @param length Length of the string to modify
+ * @param out Pointer to the character array to write to
+ *
+ * NOTE: [text, text+length) and [out, out+length) should not interleave.
+ *
+ * TODO(yazevnul): replace these functions with `bool(const TWtringBuf, const TArrayRef<wchar16>)`
+ * overload.
+ */
+bool ToLower(const wchar16* text, size_t length, wchar16* out) noexcept;
+bool ToUpper(const wchar16* text, size_t length, wchar16* out) noexcept;
+bool ToTitle(const wchar16* text, size_t length, wchar16* out) noexcept;
+
bool ToLower(const wchar32* text, size_t length, wchar32* out) noexcept;
bool ToUpper(const wchar32* text, size_t length, wchar32* out) noexcept;
bool ToTitle(const wchar32* text, size_t length, wchar32* out) noexcept;
-/* @param text Pointer to the string to modify
- * @param length Length of the string to modify
- *
- * TODO(yazevnul): replace these functions with `bool(const TArrayRef<wchar16>)` overload.
- */
-bool ToLower(wchar16* text, size_t length) noexcept;
-bool ToUpper(wchar16* text, size_t length) noexcept;
-bool ToTitle(wchar16* text, size_t length) noexcept;
-
+/* @param text Pointer to the string to modify
+ * @param length Length of the string to modify
+ *
+ * TODO(yazevnul): replace these functions with `bool(const TArrayRef<wchar16>)` overload.
+ */
+bool ToLower(wchar16* text, size_t length) noexcept;
+bool ToUpper(wchar16* text, size_t length) noexcept;
+bool ToTitle(wchar16* text, size_t length) noexcept;
+
bool ToLower(wchar32* text, size_t length) noexcept;
bool ToUpper(wchar32* text, size_t length) noexcept;
bool ToTitle(wchar32* text, size_t length) noexcept;
-/* Convenience wrappers for `ToLower`, `ToUpper` and `ToTitle`.
- */
-TUtf16String ToLowerRet(TUtf16String text, size_t pos = 0, size_t count = TUtf16String::npos) Y_WARN_UNUSED_RESULT;
-TUtf16String ToUpperRet(TUtf16String text, size_t pos = 0, size_t count = TUtf16String::npos) Y_WARN_UNUSED_RESULT;
-TUtf16String ToTitleRet(TUtf16String text, size_t pos = 0, size_t count = TUtf16String::npos) Y_WARN_UNUSED_RESULT;
-
-TUtf16String ToLowerRet(const TWtringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT;
-TUtf16String ToUpperRet(const TWtringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT;
-TUtf16String ToTitleRet(const TWtringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT;
-
+/* Convenience wrappers for `ToLower`, `ToUpper` and `ToTitle`.
+ */
+TUtf16String ToLowerRet(TUtf16String text, size_t pos = 0, size_t count = TUtf16String::npos) Y_WARN_UNUSED_RESULT;
+TUtf16String ToUpperRet(TUtf16String text, size_t pos = 0, size_t count = TUtf16String::npos) Y_WARN_UNUSED_RESULT;
+TUtf16String ToTitleRet(TUtf16String text, size_t pos = 0, size_t count = TUtf16String::npos) Y_WARN_UNUSED_RESULT;
+
+TUtf16String ToLowerRet(const TWtringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT;
+TUtf16String ToUpperRet(const TWtringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT;
+TUtf16String ToTitleRet(const TWtringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT;
+
TUtf32String ToLowerRet(const TUtf32StringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT;
TUtf32String ToUpperRet(const TUtf32StringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT;
TUtf32String ToTitleRet(const TUtf32StringBuf text, size_t pos = 0, size_t count = TWtringBuf::npos) Y_WARN_UNUSED_RESULT;
@@ -823,7 +823,7 @@ inline size_t CountWideChars(const wchar16* b, const wchar16* e) {
return count;
}
-inline size_t CountWideChars(const TWtringBuf str) {
+inline size_t CountWideChars(const TWtringBuf str) {
return CountWideChars(str.begin(), str.end());
}
@@ -838,6 +838,6 @@ inline bool IsValidUTF16(const wchar16* b, const wchar16* e) {
return true;
}
-inline bool IsValidUTF16(const TWtringBuf str) {
+inline bool IsValidUTF16(const TWtringBuf str) {
return IsValidUTF16(str.begin(), str.end());
}
diff --git a/util/charset/wide_ut.cpp b/util/charset/wide_ut.cpp
index 3d176b61c1..d8f3233e73 100644
--- a/util/charset/wide_ut.cpp
+++ b/util/charset/wide_ut.cpp
@@ -592,20 +592,20 @@ class TWideUtilTest: public TTestBase {
UNIT_TEST(TestCountWideChars);
UNIT_TEST(TestIsValidUTF16);
UNIT_TEST(TestIsStringASCII);
- UNIT_TEST(TestIsLowerWordStr);
- UNIT_TEST(TestIsUpperWordStr);
- UNIT_TEST(TestIsTitleStr);
- UNIT_TEST(TestIsLowerStr);
- UNIT_TEST(TestIsUpperStr);
- UNIT_TEST(TestToLowerStr);
- UNIT_TEST(TestToUpperStr);
- UNIT_TEST(TestToTitleStr);
+ UNIT_TEST(TestIsLowerWordStr);
+ UNIT_TEST(TestIsUpperWordStr);
+ UNIT_TEST(TestIsTitleStr);
+ UNIT_TEST(TestIsLowerStr);
+ UNIT_TEST(TestIsUpperStr);
+ UNIT_TEST(TestToLowerStr);
+ UNIT_TEST(TestToUpperStr);
+ UNIT_TEST(TestToTitleStr);
UNIT_TEST_SUITE_END();
public:
void TestCollapse() {
TUtf16String s;
- s.append(ws, Y_ARRAY_SIZE(ws)).append(3, 'a').append(ws, Y_ARRAY_SIZE(ws)).append(3, 'b').append(ws, Y_ARRAY_SIZE(ws));
+ s.append(ws, Y_ARRAY_SIZE(ws)).append(3, 'a').append(ws, Y_ARRAY_SIZE(ws)).append(3, 'b').append(ws, Y_ARRAY_SIZE(ws));
Collapse(s);
UNIT_ASSERT(s == ASCIIToWide(" aaa bbb "));
{
@@ -664,7 +664,7 @@ public:
void TestCollapseBuffer() {
TUtf16String s;
- s.append(ws, Y_ARRAY_SIZE(ws)).append(3, 'a').append(ws, Y_ARRAY_SIZE(ws)).append(3, 'b').append(ws, Y_ARRAY_SIZE(ws));
+ s.append(ws, Y_ARRAY_SIZE(ws)).append(3, 'a').append(ws, Y_ARRAY_SIZE(ws)).append(3, 'b').append(ws, Y_ARRAY_SIZE(ws));
size_t n = Collapse(s.begin(), s.size());
s.resize(n);
UNIT_ASSERT(s == ASCIIToWide(" aaa bbb "));
@@ -735,40 +735,40 @@ public:
Strip(s);
UNIT_ASSERT(s == TUtf16String());
- StripLeft(s);
- UNIT_ASSERT(s == TUtf16String());
- StripRight(s);
- UNIT_ASSERT(s == TUtf16String());
+ StripLeft(s);
+ UNIT_ASSERT(s == TUtf16String());
+ StripRight(s);
+ UNIT_ASSERT(s == TUtf16String());
s = ASCIIToWide(" \t\r\n");
Strip(s);
UNIT_ASSERT(s == TUtf16String());
- s = ASCIIToWide(" \t\r\n");
- StripLeft(s);
- UNIT_ASSERT(s == TUtf16String());
- s = ASCIIToWide(" \t\r\n");
- StripRight(s);
- UNIT_ASSERT(s == TUtf16String());
+ s = ASCIIToWide(" \t\r\n");
+ StripLeft(s);
+ UNIT_ASSERT(s == TUtf16String());
+ s = ASCIIToWide(" \t\r\n");
+ StripRight(s);
+ UNIT_ASSERT(s == TUtf16String());
s = ASCIIToWide("\t\f\va \r\n");
Strip(s);
UNIT_ASSERT(s == ASCIIToWide("a"));
- s = ASCIIToWide("\t\f\va \r\n");
- StripLeft(s);
- UNIT_ASSERT(s == ASCIIToWide("a \r\n"));
- s = ASCIIToWide("\t\f\va \r\n");
- StripRight(s);
- UNIT_ASSERT(s == ASCIIToWide("\t\f\va"));
+ s = ASCIIToWide("\t\f\va \r\n");
+ StripLeft(s);
+ UNIT_ASSERT(s == ASCIIToWide("a \r\n"));
+ s = ASCIIToWide("\t\f\va \r\n");
+ StripRight(s);
+ UNIT_ASSERT(s == ASCIIToWide("\t\f\va"));
s = ASCIIToWide("\r\na\r\nb\t\tc\r\n");
Strip(s);
UNIT_ASSERT(s == ASCIIToWide("a\r\nb\t\tc"));
- s = ASCIIToWide("\r\na\r\nb\t\tc\r\n");
- StripLeft(s);
- UNIT_ASSERT(s == ASCIIToWide("a\r\nb\t\tc\r\n"));
- s = ASCIIToWide("\r\na\r\nb\t\tc\r\n");
- StripRight(s);
- UNIT_ASSERT(s == ASCIIToWide("\r\na\r\nb\t\tc"));
+ s = ASCIIToWide("\r\na\r\nb\t\tc\r\n");
+ StripLeft(s);
+ UNIT_ASSERT(s == ASCIIToWide("a\r\nb\t\tc\r\n"));
+ s = ASCIIToWide("\r\na\r\nb\t\tc\r\n");
+ StripRight(s);
+ UNIT_ASSERT(s == ASCIIToWide("\r\na\r\nb\t\tc"));
const TUtf16String w(ASCIIToWide("a b"));
s = w;
@@ -777,24 +777,24 @@ public:
#ifndef TSTRING_IS_STD_STRING
UNIT_ASSERT(s.c_str() == w.c_str()); // Strip() does not change the string at all
#endif
- s = w;
- StripLeft(s);
- UNIT_ASSERT(s == w);
+ s = w;
+ StripLeft(s);
+ UNIT_ASSERT(s == w);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.c_str() == w.c_str()); // Strip() does not change the string at all
+ UNIT_ASSERT(s.c_str() == w.c_str()); // Strip() does not change the string at all
#endif
- s = w;
- StripRight(s);
- UNIT_ASSERT(s == w);
+ s = w;
+ StripRight(s);
+ UNIT_ASSERT(s == w);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.c_str() == w.c_str()); // Strip() does not change the string at all
+ UNIT_ASSERT(s.c_str() == w.c_str()); // Strip() does not change the string at all
#endif
}
void TestIsSpace() {
UNIT_ASSERT(!IsSpace(TUtf16String()));
- UNIT_ASSERT(IsSpace(ws, Y_ARRAY_SIZE(ws)));
+ UNIT_ASSERT(IsSpace(ws, Y_ARRAY_SIZE(ws)));
TUtf16String w;
w.assign(ws, Y_ARRAY_SIZE(ws)).append(TUtf16String(1, '!'));
@@ -983,760 +983,760 @@ public:
}
}
}
-
- void TestIsLowerWordStr() {
- UNIT_ASSERT(IsLowerWord(TWtringBuf()));
- UNIT_ASSERT(IsLowerWord(UTF8ToWide("")));
- UNIT_ASSERT(IsLowerWord(UTF8ToWide("test")));
+
+ void TestIsLowerWordStr() {
+ UNIT_ASSERT(IsLowerWord(TWtringBuf()));
+ UNIT_ASSERT(IsLowerWord(UTF8ToWide("")));
+ UNIT_ASSERT(IsLowerWord(UTF8ToWide("test")));
UNIT_ASSERT(IsLowerWord(UTF8ToWide("тест"))); // "тест" is "test" in russian (cyrrilic)
- UNIT_ASSERT(!IsLowerWord(UTF8ToWide("тест тест")));
- UNIT_ASSERT(!IsLowerWord(UTF8ToWide("тест100500")));
-
- UNIT_ASSERT(!IsLowerWord(UTF8ToWide("Test")));
- UNIT_ASSERT(!IsLowerWord(UTF8ToWide("tesT")));
- UNIT_ASSERT(!IsLowerWord(UTF8ToWide("tEst")));
-
- UNIT_ASSERT(!IsLowerWord(UTF8ToWide("Тест")));
- UNIT_ASSERT(!IsLowerWord(UTF8ToWide("теСт")));
- UNIT_ASSERT(!IsLowerWord(UTF8ToWide("тесТ")));
- }
-
- void TestIsUpperWordStr() {
- UNIT_ASSERT(IsUpperWord(TWtringBuf()));
- UNIT_ASSERT(IsUpperWord(UTF8ToWide("")));
- UNIT_ASSERT(IsUpperWord(UTF8ToWide("TEST")));
- UNIT_ASSERT(IsUpperWord(UTF8ToWide("ТЕСТ")));
- UNIT_ASSERT(!IsUpperWord(UTF8ToWide("тест тест")));
- UNIT_ASSERT(!IsUpperWord(UTF8ToWide("тест100500")));
-
- UNIT_ASSERT(!IsUpperWord(UTF8ToWide("Test")));
- UNIT_ASSERT(!IsUpperWord(UTF8ToWide("tesT")));
- UNIT_ASSERT(!IsUpperWord(UTF8ToWide("tEst")));
-
- UNIT_ASSERT(!IsUpperWord(UTF8ToWide("Тест")));
- UNIT_ASSERT(!IsUpperWord(UTF8ToWide("теСт")));
- UNIT_ASSERT(!IsUpperWord(UTF8ToWide("тесТ")));
- }
-
- void TestIsTitleStr() {
- UNIT_ASSERT(!IsTitleWord(TWtringBuf()));
- UNIT_ASSERT(!IsTitleWord(UTF8ToWide("")));
- UNIT_ASSERT(!IsTitleWord(UTF8ToWide("t")));
- UNIT_ASSERT(!IsTitleWord(UTF8ToWide("й")));
- UNIT_ASSERT(IsTitleWord(UTF8ToWide("T")));
- UNIT_ASSERT(IsTitleWord(UTF8ToWide("Й")));
- UNIT_ASSERT(IsTitleWord(UTF8ToWide("Test")));
- UNIT_ASSERT(IsTitleWord(UTF8ToWide("Тест")));
- UNIT_ASSERT(!IsTitleWord(UTF8ToWide("тест тест")));
- UNIT_ASSERT(!IsTitleWord(UTF8ToWide("тест100500")));
- UNIT_ASSERT(!IsTitleWord(UTF8ToWide("Тест тест")));
- UNIT_ASSERT(!IsTitleWord(UTF8ToWide("Тест100500")));
-
- UNIT_ASSERT(!IsTitleWord(UTF8ToWide("tesT")));
- UNIT_ASSERT(!IsTitleWord(UTF8ToWide("tEst")));
-
- UNIT_ASSERT(!IsTitleWord(UTF8ToWide("теСт")));
- UNIT_ASSERT(!IsTitleWord(UTF8ToWide("тесТ")));
- }
-
- void TestIsLowerStr() {
- UNIT_ASSERT(IsLower(TWtringBuf()));
- UNIT_ASSERT(IsLower(UTF8ToWide("")));
- UNIT_ASSERT(IsLower(UTF8ToWide("test")));
+ UNIT_ASSERT(!IsLowerWord(UTF8ToWide("тест тест")));
+ UNIT_ASSERT(!IsLowerWord(UTF8ToWide("тест100500")));
+
+ UNIT_ASSERT(!IsLowerWord(UTF8ToWide("Test")));
+ UNIT_ASSERT(!IsLowerWord(UTF8ToWide("tesT")));
+ UNIT_ASSERT(!IsLowerWord(UTF8ToWide("tEst")));
+
+ UNIT_ASSERT(!IsLowerWord(UTF8ToWide("Тест")));
+ UNIT_ASSERT(!IsLowerWord(UTF8ToWide("теСт")));
+ UNIT_ASSERT(!IsLowerWord(UTF8ToWide("тесТ")));
+ }
+
+ void TestIsUpperWordStr() {
+ UNIT_ASSERT(IsUpperWord(TWtringBuf()));
+ UNIT_ASSERT(IsUpperWord(UTF8ToWide("")));
+ UNIT_ASSERT(IsUpperWord(UTF8ToWide("TEST")));
+ UNIT_ASSERT(IsUpperWord(UTF8ToWide("ТЕСТ")));
+ UNIT_ASSERT(!IsUpperWord(UTF8ToWide("тест тест")));
+ UNIT_ASSERT(!IsUpperWord(UTF8ToWide("тест100500")));
+
+ UNIT_ASSERT(!IsUpperWord(UTF8ToWide("Test")));
+ UNIT_ASSERT(!IsUpperWord(UTF8ToWide("tesT")));
+ UNIT_ASSERT(!IsUpperWord(UTF8ToWide("tEst")));
+
+ UNIT_ASSERT(!IsUpperWord(UTF8ToWide("Тест")));
+ UNIT_ASSERT(!IsUpperWord(UTF8ToWide("теСт")));
+ UNIT_ASSERT(!IsUpperWord(UTF8ToWide("тесТ")));
+ }
+
+ void TestIsTitleStr() {
+ UNIT_ASSERT(!IsTitleWord(TWtringBuf()));
+ UNIT_ASSERT(!IsTitleWord(UTF8ToWide("")));
+ UNIT_ASSERT(!IsTitleWord(UTF8ToWide("t")));
+ UNIT_ASSERT(!IsTitleWord(UTF8ToWide("й")));
+ UNIT_ASSERT(IsTitleWord(UTF8ToWide("T")));
+ UNIT_ASSERT(IsTitleWord(UTF8ToWide("Й")));
+ UNIT_ASSERT(IsTitleWord(UTF8ToWide("Test")));
+ UNIT_ASSERT(IsTitleWord(UTF8ToWide("Тест")));
+ UNIT_ASSERT(!IsTitleWord(UTF8ToWide("тест тест")));
+ UNIT_ASSERT(!IsTitleWord(UTF8ToWide("тест100500")));
+ UNIT_ASSERT(!IsTitleWord(UTF8ToWide("Тест тест")));
+ UNIT_ASSERT(!IsTitleWord(UTF8ToWide("Тест100500")));
+
+ UNIT_ASSERT(!IsTitleWord(UTF8ToWide("tesT")));
+ UNIT_ASSERT(!IsTitleWord(UTF8ToWide("tEst")));
+
+ UNIT_ASSERT(!IsTitleWord(UTF8ToWide("теСт")));
+ UNIT_ASSERT(!IsTitleWord(UTF8ToWide("тесТ")));
+ }
+
+ void TestIsLowerStr() {
+ UNIT_ASSERT(IsLower(TWtringBuf()));
+ UNIT_ASSERT(IsLower(UTF8ToWide("")));
+ UNIT_ASSERT(IsLower(UTF8ToWide("test")));
UNIT_ASSERT(IsLower(UTF8ToWide("тест"))); // "тест" is "test" in russian (cyrrilic)
- UNIT_ASSERT(IsLower(UTF8ToWide("тест тест")));
- UNIT_ASSERT(IsLower(UTF8ToWide("тест100500")));
-
- UNIT_ASSERT(!IsLower(UTF8ToWide("Test")));
- UNIT_ASSERT(!IsLower(UTF8ToWide("tesT")));
- UNIT_ASSERT(!IsLower(UTF8ToWide("tEst")));
-
- UNIT_ASSERT(!IsLower(UTF8ToWide("Тест")));
- UNIT_ASSERT(!IsLower(UTF8ToWide("теСт")));
- UNIT_ASSERT(!IsLower(UTF8ToWide("тесТ")));
- }
-
- void TestIsUpperStr() {
- UNIT_ASSERT(IsUpper(TWtringBuf()));
- UNIT_ASSERT(IsUpper(UTF8ToWide("")));
- UNIT_ASSERT(IsUpper(UTF8ToWide("TEST")));
- UNIT_ASSERT(IsUpper(UTF8ToWide("ТЕСТ")));
- UNIT_ASSERT(IsUpper(UTF8ToWide("ТЕСТ ТЕСТ")));
- UNIT_ASSERT(IsUpper(UTF8ToWide("ТЕСТ100500")));
-
- UNIT_ASSERT(!IsUpper(UTF8ToWide("Test")));
- UNIT_ASSERT(!IsUpper(UTF8ToWide("tesT")));
- UNIT_ASSERT(!IsUpper(UTF8ToWide("tEst")));
-
- UNIT_ASSERT(!IsUpper(UTF8ToWide("Тест")));
- UNIT_ASSERT(!IsUpper(UTF8ToWide("теСт")));
- UNIT_ASSERT(!IsUpper(UTF8ToWide("тесТ")));
- }
-
- void TestToLowerStr() {
- // In these test and test for `ToUpper` and `ToTitle` we are checking that string keep
- // pointing to the same piece of memory we are doing it the following way:
- //
- // TUtf16String s = ...
- // const auto copy = s;
- // ...
- // UNIT_ASSERT(s.data() == copy.data())
- //
- // It saves us a couple lines (we are reusing `copy` later) and if one day `TString` will
- // become non-refcounted we'll need to rewrite it to something like:
- //
- // TUtf16String s = ...
- // const auto* const data = s.data();
- // const auto length = s.length();
- // ...
- // UNIT_ASSERT(s.data() == data);
- // UNIT_ASSERT(s.length() == length);
- {
- TUtf16String s;
- auto writableCopy = s;
- const auto copy = s;
- const TUtf16String lower;
-
- UNIT_ASSERT(!ToLower(s));
- UNIT_ASSERT(s == lower);
+ UNIT_ASSERT(IsLower(UTF8ToWide("тест тест")));
+ UNIT_ASSERT(IsLower(UTF8ToWide("тест100500")));
+
+ UNIT_ASSERT(!IsLower(UTF8ToWide("Test")));
+ UNIT_ASSERT(!IsLower(UTF8ToWide("tesT")));
+ UNIT_ASSERT(!IsLower(UTF8ToWide("tEst")));
+
+ UNIT_ASSERT(!IsLower(UTF8ToWide("Тест")));
+ UNIT_ASSERT(!IsLower(UTF8ToWide("теСт")));
+ UNIT_ASSERT(!IsLower(UTF8ToWide("тесТ")));
+ }
+
+ void TestIsUpperStr() {
+ UNIT_ASSERT(IsUpper(TWtringBuf()));
+ UNIT_ASSERT(IsUpper(UTF8ToWide("")));
+ UNIT_ASSERT(IsUpper(UTF8ToWide("TEST")));
+ UNIT_ASSERT(IsUpper(UTF8ToWide("ТЕСТ")));
+ UNIT_ASSERT(IsUpper(UTF8ToWide("ТЕСТ ТЕСТ")));
+ UNIT_ASSERT(IsUpper(UTF8ToWide("ТЕСТ100500")));
+
+ UNIT_ASSERT(!IsUpper(UTF8ToWide("Test")));
+ UNIT_ASSERT(!IsUpper(UTF8ToWide("tesT")));
+ UNIT_ASSERT(!IsUpper(UTF8ToWide("tEst")));
+
+ UNIT_ASSERT(!IsUpper(UTF8ToWide("Тест")));
+ UNIT_ASSERT(!IsUpper(UTF8ToWide("теСт")));
+ UNIT_ASSERT(!IsUpper(UTF8ToWide("тесТ")));
+ }
+
+ void TestToLowerStr() {
+ // In these test and test for `ToUpper` and `ToTitle` we are checking that string keep
+ // pointing to the same piece of memory we are doing it the following way:
+ //
+ // TUtf16String s = ...
+ // const auto copy = s;
+ // ...
+ // UNIT_ASSERT(s.data() == copy.data())
+ //
+ // It saves us a couple lines (we are reusing `copy` later) and if one day `TString` will
+ // become non-refcounted we'll need to rewrite it to something like:
+ //
+ // TUtf16String s = ...
+ // const auto* const data = s.data();
+ // const auto length = s.length();
+ // ...
+ // UNIT_ASSERT(s.data() == data);
+ // UNIT_ASSERT(s.length() == length);
+ {
+ TUtf16String s;
+ auto writableCopy = s;
+ const auto copy = s;
+ const TUtf16String lower;
+
+ UNIT_ASSERT(!ToLower(s));
+ UNIT_ASSERT(s == lower);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == lower);
-
- UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == lower);
-
- UNIT_ASSERT(ToLowerRet(copy) == lower);
- UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower);
- }
- {
- TUtf16String s = UTF8ToWide("");
- auto writableCopy = s;
- const auto copy = s;
- const TUtf16String lower;
-
- UNIT_ASSERT(!ToLower(s));
- UNIT_ASSERT(s == lower);
+
+ UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == lower);
+
+ UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == lower);
+
+ UNIT_ASSERT(ToLowerRet(copy) == lower);
+ UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower);
+ }
+ {
+ TUtf16String s = UTF8ToWide("");
+ auto writableCopy = s;
+ const auto copy = s;
+ const TUtf16String lower;
+
+ UNIT_ASSERT(!ToLower(s));
+ UNIT_ASSERT(s == lower);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == lower);
-
- UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == lower);
-
- UNIT_ASSERT(ToLowerRet(copy) == lower);
- UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower);
- }
- {
- TUtf16String s;
- const auto copy = s;
- const TUtf16String lower;
-
- UNIT_ASSERT(!ToLower(s, 100500));
- UNIT_ASSERT(s == lower);
+
+ UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == lower);
+
+ UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == lower);
+
+ UNIT_ASSERT(ToLowerRet(copy) == lower);
+ UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower);
+ }
+ {
+ TUtf16String s;
+ const auto copy = s;
+ const TUtf16String lower;
+
+ UNIT_ASSERT(!ToLower(s, 100500));
+ UNIT_ASSERT(s == lower);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(ToLowerRet(copy, 100500) == lower);
- UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 100500) == lower);
- }
- {
- TUtf16String s;
- const auto copy = s;
- const TUtf16String lower;
-
- UNIT_ASSERT(!ToLower(s, 100500, 1111));
- UNIT_ASSERT(s == lower);
+
+ UNIT_ASSERT(ToLowerRet(copy, 100500) == lower);
+ UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 100500) == lower);
+ }
+ {
+ TUtf16String s;
+ const auto copy = s;
+ const TUtf16String lower;
+
+ UNIT_ASSERT(!ToLower(s, 100500, 1111));
+ UNIT_ASSERT(s == lower);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(ToLowerRet(copy, 100500, 1111) == lower);
- UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 100500, 1111) == lower);
- }
- {
- auto s = UTF8ToWide("Й");
- auto writableCopy = s;
- const auto copy = s;
- const auto lower = UTF8ToWide("й");
-
- UNIT_ASSERT(ToLower(s));
- UNIT_ASSERT(s == lower);
-
- UNIT_ASSERT(ToLower(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == lower);
-
- UNIT_ASSERT(ToLower(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == lower);
-
- UNIT_ASSERT(ToLowerRet(copy) == lower);
- UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower);
- }
- {
- auto s = UTF8ToWide("й");
- auto writableCopy = s;
- const auto copy = s;
- const auto lower = UTF8ToWide("й");
-
- UNIT_ASSERT(!ToLower(s));
- UNIT_ASSERT(s == lower);
+
+ UNIT_ASSERT(ToLowerRet(copy, 100500, 1111) == lower);
+ UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 100500, 1111) == lower);
+ }
+ {
+ auto s = UTF8ToWide("Й");
+ auto writableCopy = s;
+ const auto copy = s;
+ const auto lower = UTF8ToWide("й");
+
+ UNIT_ASSERT(ToLower(s));
+ UNIT_ASSERT(s == lower);
+
+ UNIT_ASSERT(ToLower(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == lower);
+
+ UNIT_ASSERT(ToLower(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == lower);
+
+ UNIT_ASSERT(ToLowerRet(copy) == lower);
+ UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower);
+ }
+ {
+ auto s = UTF8ToWide("й");
+ auto writableCopy = s;
+ const auto copy = s;
+ const auto lower = UTF8ToWide("й");
+
+ UNIT_ASSERT(!ToLower(s));
+ UNIT_ASSERT(s == lower);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == lower);
-
- UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == lower);
-
- UNIT_ASSERT(ToLowerRet(copy) == lower);
- UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower);
- }
- {
- auto s = UTF8ToWide("тест");
- auto writableCopy = s;
- const auto copy = s;
- const auto lower = UTF8ToWide("тест");
-
- UNIT_ASSERT(!ToLower(s));
- UNIT_ASSERT(s == lower);
+
+ UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == lower);
+
+ UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == lower);
+
+ UNIT_ASSERT(ToLowerRet(copy) == lower);
+ UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower);
+ }
+ {
+ auto s = UTF8ToWide("тест");
+ auto writableCopy = s;
+ const auto copy = s;
+ const auto lower = UTF8ToWide("тест");
+
+ UNIT_ASSERT(!ToLower(s));
+ UNIT_ASSERT(s == lower);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == lower);
-
- UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == lower);
-
- UNIT_ASSERT(ToLowerRet(copy) == lower);
- UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower);
- }
- {
- auto s = UTF8ToWide("Тест");
- auto writableCopy = s;
- const auto copy = s;
- const auto lower = UTF8ToWide("тест");
-
- UNIT_ASSERT(ToLower(s));
- UNIT_ASSERT(s == lower);
-
- UNIT_ASSERT(ToLower(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == lower);
-
- UNIT_ASSERT(ToLower(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == lower);
-
- UNIT_ASSERT(ToLowerRet(copy) == lower);
- UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower);
- }
- {
- TUtf16String s = UTF8ToWide("тЕст");
- const auto copy = s;
- const auto lower = UTF8ToWide("тест");
-
- UNIT_ASSERT(ToLower(s));
- UNIT_ASSERT(s == UTF8ToWide("тест"));
-
- UNIT_ASSERT(ToLowerRet(copy) == lower);
- UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower);
- }
- {
- auto s = UTF8ToWide("тЕст");
- const auto copy = s;
- const auto lower = UTF8ToWide("тЕст");
-
- UNIT_ASSERT(!ToLower(s, 2));
- UNIT_ASSERT(s == lower);
+
+ UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == lower);
+
+ UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == lower);
+
+ UNIT_ASSERT(ToLowerRet(copy) == lower);
+ UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower);
+ }
+ {
+ auto s = UTF8ToWide("Тест");
+ auto writableCopy = s;
+ const auto copy = s;
+ const auto lower = UTF8ToWide("тест");
+
+ UNIT_ASSERT(ToLower(s));
+ UNIT_ASSERT(s == lower);
+
+ UNIT_ASSERT(ToLower(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == lower);
+
+ UNIT_ASSERT(ToLower(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == lower);
+
+ UNIT_ASSERT(ToLowerRet(copy) == lower);
+ UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower);
+ }
+ {
+ TUtf16String s = UTF8ToWide("тЕст");
+ const auto copy = s;
+ const auto lower = UTF8ToWide("тест");
+
+ UNIT_ASSERT(ToLower(s));
+ UNIT_ASSERT(s == UTF8ToWide("тест"));
+
+ UNIT_ASSERT(ToLowerRet(copy) == lower);
+ UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower);
+ }
+ {
+ auto s = UTF8ToWide("тЕст");
+ const auto copy = s;
+ const auto lower = UTF8ToWide("тЕст");
+
+ UNIT_ASSERT(!ToLower(s, 2));
+ UNIT_ASSERT(s == lower);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(ToLowerRet(copy, 2) == lower);
- UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 2) == lower);
- }
- {
- auto s = UTF8ToWide("теСт");
- const auto copy = s;
- const auto lower = UTF8ToWide("тест");
-
- UNIT_ASSERT(ToLower(s, 2));
- UNIT_ASSERT(s == lower);
-
- UNIT_ASSERT(ToLowerRet(copy, 2) == lower);
- UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 2) == lower);
- }
- {
- auto s = UTF8ToWide("теСт");
- const auto copy = s;
- const auto lower = UTF8ToWide("теСт");
-
- UNIT_ASSERT(!ToLower(s, 3, 1));
- UNIT_ASSERT(s == copy);
+
+ UNIT_ASSERT(ToLowerRet(copy, 2) == lower);
+ UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 2) == lower);
+ }
+ {
+ auto s = UTF8ToWide("теСт");
+ const auto copy = s;
+ const auto lower = UTF8ToWide("тест");
+
+ UNIT_ASSERT(ToLower(s, 2));
+ UNIT_ASSERT(s == lower);
+
+ UNIT_ASSERT(ToLowerRet(copy, 2) == lower);
+ UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 2) == lower);
+ }
+ {
+ auto s = UTF8ToWide("теСт");
+ const auto copy = s;
+ const auto lower = UTF8ToWide("теСт");
+
+ UNIT_ASSERT(!ToLower(s, 3, 1));
+ UNIT_ASSERT(s == copy);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(ToLowerRet(copy, 3, 1) == lower);
- UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 3, 1) == lower);
- }
- {
- auto s = UTF8ToWide("теСт");
- const auto copy = s;
- const auto lower = UTF8ToWide("теСт");
-
- UNIT_ASSERT(!ToLower(s, 3, 100500));
- UNIT_ASSERT(s == copy);
+
+ UNIT_ASSERT(ToLowerRet(copy, 3, 1) == lower);
+ UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 3, 1) == lower);
+ }
+ {
+ auto s = UTF8ToWide("теСт");
+ const auto copy = s;
+ const auto lower = UTF8ToWide("теСт");
+
+ UNIT_ASSERT(!ToLower(s, 3, 100500));
+ UNIT_ASSERT(s == copy);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(ToLowerRet(copy, 3, 100500) == lower);
- UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 3, 100500) == lower);
- }
- }
-
- void TestToUpperStr() {
- {
- TUtf16String s;
- auto writableCopy = s;
- const auto copy = s;
- const TUtf16String upper;
-
- UNIT_ASSERT(!ToUpper(s));
- UNIT_ASSERT(s == upper);
+
+ UNIT_ASSERT(ToLowerRet(copy, 3, 100500) == lower);
+ UNIT_ASSERT(ToLowerRet(TWtringBuf(copy), 3, 100500) == lower);
+ }
+ }
+
+ void TestToUpperStr() {
+ {
+ TUtf16String s;
+ auto writableCopy = s;
+ const auto copy = s;
+ const TUtf16String upper;
+
+ UNIT_ASSERT(!ToUpper(s));
+ UNIT_ASSERT(s == upper);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(ToUpperRet(copy) == upper);
- UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper);
- }
- {
- auto s = UTF8ToWide("");
- auto writableCopy = s;
- const auto copy = s;
- const TUtf16String upper;
-
- UNIT_ASSERT(!ToUpper(s));
- UNIT_ASSERT(s == upper);
+
+ UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(ToUpperRet(copy) == upper);
+ UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper);
+ }
+ {
+ auto s = UTF8ToWide("");
+ auto writableCopy = s;
+ const auto copy = s;
+ const TUtf16String upper;
+
+ UNIT_ASSERT(!ToUpper(s));
+ UNIT_ASSERT(s == upper);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(ToUpperRet(copy) == upper);
- UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper);
- }
- {
- TUtf16String s;
- auto writableCopy = s;
- const auto copy = s;
- const TUtf16String upper;
-
- UNIT_ASSERT(!ToUpper(s, 100500));
- UNIT_ASSERT(s == upper);
+
+ UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(ToUpperRet(copy) == upper);
+ UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper);
+ }
+ {
+ TUtf16String s;
+ auto writableCopy = s;
+ const auto copy = s;
+ const TUtf16String upper;
+
+ UNIT_ASSERT(!ToUpper(s, 100500));
+ UNIT_ASSERT(s == upper);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(ToUpperRet(copy, 100500) == upper);
- UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 100500) == upper);
- }
- {
- TUtf16String s;
- const auto copy = s;
- const TUtf16String upper;
-
- UNIT_ASSERT(!ToUpper(s, 100500, 1111));
- UNIT_ASSERT(s == upper);
+
+ UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(ToUpperRet(copy, 100500) == upper);
+ UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 100500) == upper);
+ }
+ {
+ TUtf16String s;
+ const auto copy = s;
+ const TUtf16String upper;
+
+ UNIT_ASSERT(!ToUpper(s, 100500, 1111));
+ UNIT_ASSERT(s == upper);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(ToUpperRet(copy, 100500, 1111) == upper);
- UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 100500, 1111) == upper);
- }
- {
- auto s = UTF8ToWide("й");
- auto writableCopy = s;
- const auto copy = s;
- const auto upper = UTF8ToWide("Й");
-
- UNIT_ASSERT(ToUpper(s));
- UNIT_ASSERT(s == upper);
-
- UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(ToUpperRet(copy) == upper);
- UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper);
- }
- {
- auto s = UTF8ToWide("Й");
- auto writableCopy = s;
- const auto copy = s;
- const auto upper = UTF8ToWide("Й");
-
- UNIT_ASSERT(!ToUpper(s));
- UNIT_ASSERT(s == copy);
+
+ UNIT_ASSERT(ToUpperRet(copy, 100500, 1111) == upper);
+ UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 100500, 1111) == upper);
+ }
+ {
+ auto s = UTF8ToWide("й");
+ auto writableCopy = s;
+ const auto copy = s;
+ const auto upper = UTF8ToWide("Й");
+
+ UNIT_ASSERT(ToUpper(s));
+ UNIT_ASSERT(s == upper);
+
+ UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(ToUpperRet(copy) == upper);
+ UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper);
+ }
+ {
+ auto s = UTF8ToWide("Й");
+ auto writableCopy = s;
+ const auto copy = s;
+ const auto upper = UTF8ToWide("Й");
+
+ UNIT_ASSERT(!ToUpper(s));
+ UNIT_ASSERT(s == copy);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(ToUpperRet(copy) == upper);
- UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper);
- }
- {
- auto s = UTF8ToWide("тест");
- auto writableCopy = s;
- const auto copy = s;
- const auto upper = UTF8ToWide("ТЕСТ");
-
- UNIT_ASSERT(ToUpper(s));
- UNIT_ASSERT(s == upper);
-
- UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(ToUpperRet(copy) == upper);
- UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper);
- }
- {
- auto s = UTF8ToWide("Тест");
- auto writableCopy = s;
- const auto copy = s;
- const auto upper = UTF8ToWide("ТЕСТ");
-
- UNIT_ASSERT(ToUpper(s));
- UNIT_ASSERT(s == upper);
-
- UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(ToUpperRet(copy) == upper);
- UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper);
- }
- {
- auto s = UTF8ToWide("тЕст");
- auto writableCopy = s;
- const auto copy = s;
- const auto upper = UTF8ToWide("ТЕСТ");
-
- UNIT_ASSERT(ToUpper(s));
- UNIT_ASSERT(s == upper);
-
- UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == upper);
-
- UNIT_ASSERT(ToUpperRet(copy) == upper);
- UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper);
- }
- {
- auto s = UTF8ToWide("тЕст");
- const auto copy = s;
- const auto upper = UTF8ToWide("тЕСТ");
-
- UNIT_ASSERT(ToUpper(s, 2));
- UNIT_ASSERT(s == upper);
-
- UNIT_ASSERT(ToUpperRet(copy, 2) == upper);
- UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 2) == upper);
- }
- {
- auto s = UTF8ToWide("теСт");
- const auto copy = s;
- const auto upper = UTF8ToWide("теСТ");
-
- UNIT_ASSERT(ToUpper(s, 2));
- UNIT_ASSERT(s == upper);
-
- UNIT_ASSERT(ToUpperRet(copy, 2) == upper);
- UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 2) == upper);
- }
- {
- auto s = UTF8ToWide("теСт");
- const auto copy = s;
- const auto upper = UTF8ToWide("теСТ");
-
- UNIT_ASSERT(ToUpper(s, 3, 1));
- UNIT_ASSERT(s == upper);
-
- UNIT_ASSERT(ToUpperRet(copy, 3, 1) == upper);
- UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 3, 1) == upper);
- }
- {
- auto s = UTF8ToWide("теСт");
- const auto copy = s;
- const auto upper = UTF8ToWide("теСТ");
-
- UNIT_ASSERT(ToUpper(s, 3, 100500));
- UNIT_ASSERT(s == upper);
-
- UNIT_ASSERT(ToUpperRet(copy, 3, 100500) == upper);
- UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 3, 100500) == upper);
- }
- }
-
- void TestToTitleStr() {
- {
- TUtf16String s;
- auto writableCopy = s;
- const auto copy = s;
- const TUtf16String title;
-
- UNIT_ASSERT(!ToTitle(s));
- UNIT_ASSERT(s == title);
+
+ UNIT_ASSERT(!ToUpper(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(!ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(ToUpperRet(copy) == upper);
+ UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper);
+ }
+ {
+ auto s = UTF8ToWide("тест");
+ auto writableCopy = s;
+ const auto copy = s;
+ const auto upper = UTF8ToWide("ТЕСТ");
+
+ UNIT_ASSERT(ToUpper(s));
+ UNIT_ASSERT(s == upper);
+
+ UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(ToUpperRet(copy) == upper);
+ UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper);
+ }
+ {
+ auto s = UTF8ToWide("Тест");
+ auto writableCopy = s;
+ const auto copy = s;
+ const auto upper = UTF8ToWide("ТЕСТ");
+
+ UNIT_ASSERT(ToUpper(s));
+ UNIT_ASSERT(s == upper);
+
+ UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(ToUpperRet(copy) == upper);
+ UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper);
+ }
+ {
+ auto s = UTF8ToWide("тЕст");
+ auto writableCopy = s;
+ const auto copy = s;
+ const auto upper = UTF8ToWide("ТЕСТ");
+
+ UNIT_ASSERT(ToUpper(s));
+ UNIT_ASSERT(s == upper);
+
+ UNIT_ASSERT(ToUpper(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(ToUpper(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == upper);
+
+ UNIT_ASSERT(ToUpperRet(copy) == upper);
+ UNIT_ASSERT(ToUpperRet(TWtringBuf(copy)) == upper);
+ }
+ {
+ auto s = UTF8ToWide("тЕст");
+ const auto copy = s;
+ const auto upper = UTF8ToWide("тЕСТ");
+
+ UNIT_ASSERT(ToUpper(s, 2));
+ UNIT_ASSERT(s == upper);
+
+ UNIT_ASSERT(ToUpperRet(copy, 2) == upper);
+ UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 2) == upper);
+ }
+ {
+ auto s = UTF8ToWide("теСт");
+ const auto copy = s;
+ const auto upper = UTF8ToWide("теСТ");
+
+ UNIT_ASSERT(ToUpper(s, 2));
+ UNIT_ASSERT(s == upper);
+
+ UNIT_ASSERT(ToUpperRet(copy, 2) == upper);
+ UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 2) == upper);
+ }
+ {
+ auto s = UTF8ToWide("теСт");
+ const auto copy = s;
+ const auto upper = UTF8ToWide("теСТ");
+
+ UNIT_ASSERT(ToUpper(s, 3, 1));
+ UNIT_ASSERT(s == upper);
+
+ UNIT_ASSERT(ToUpperRet(copy, 3, 1) == upper);
+ UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 3, 1) == upper);
+ }
+ {
+ auto s = UTF8ToWide("теСт");
+ const auto copy = s;
+ const auto upper = UTF8ToWide("теСТ");
+
+ UNIT_ASSERT(ToUpper(s, 3, 100500));
+ UNIT_ASSERT(s == upper);
+
+ UNIT_ASSERT(ToUpperRet(copy, 3, 100500) == upper);
+ UNIT_ASSERT(ToUpperRet(TWtringBuf(copy), 3, 100500) == upper);
+ }
+ }
+
+ void TestToTitleStr() {
+ {
+ TUtf16String s;
+ auto writableCopy = s;
+ const auto copy = s;
+ const TUtf16String title;
+
+ UNIT_ASSERT(!ToTitle(s));
+ UNIT_ASSERT(s == title);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == title);
-
- UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == title);
-
- UNIT_ASSERT(ToTitleRet(copy) == title);
- UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
- }
- {
- auto s = UTF8ToWide("");
- auto writableCopy = s;
- const auto copy = s;
- const TUtf16String title;
-
- UNIT_ASSERT(!ToTitle(s));
- UNIT_ASSERT(s == title);
+
+ UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == title);
+
+ UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == title);
+
+ UNIT_ASSERT(ToTitleRet(copy) == title);
+ UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
+ }
+ {
+ auto s = UTF8ToWide("");
+ auto writableCopy = s;
+ const auto copy = s;
+ const TUtf16String title;
+
+ UNIT_ASSERT(!ToTitle(s));
+ UNIT_ASSERT(s == title);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == title);
-
- UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == title);
-
- UNIT_ASSERT(ToTitleRet(copy) == title);
- UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
- }
- {
- TUtf16String s;
- const auto copy = s;
- const TUtf16String title;
-
- UNIT_ASSERT(!ToTitle(s, 100500));
- UNIT_ASSERT(s == title);
+
+ UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == title);
+
+ UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == title);
+
+ UNIT_ASSERT(ToTitleRet(copy) == title);
+ UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
+ }
+ {
+ TUtf16String s;
+ const auto copy = s;
+ const TUtf16String title;
+
+ UNIT_ASSERT(!ToTitle(s, 100500));
+ UNIT_ASSERT(s == title);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(ToTitleRet(copy) == title);
- UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
- }
- {
- TUtf16String s;
- const auto copy = s;
- const TUtf16String title;
-
- UNIT_ASSERT(!ToTitle(s, 100500, 1111));
- UNIT_ASSERT(s == title);
+
+ UNIT_ASSERT(ToTitleRet(copy) == title);
+ UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
+ }
+ {
+ TUtf16String s;
+ const auto copy = s;
+ const TUtf16String title;
+
+ UNIT_ASSERT(!ToTitle(s, 100500, 1111));
+ UNIT_ASSERT(s == title);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(ToTitleRet(copy) == title);
- UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
- }
- {
- auto s = UTF8ToWide("й");
- auto writableCopy = s;
- const auto copy = s;
- const auto title = UTF8ToWide("Й");
-
- UNIT_ASSERT(ToTitle(s));
- UNIT_ASSERT(s == title);
-
- UNIT_ASSERT(ToTitle(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == title);
-
- UNIT_ASSERT(ToTitle(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == title);
-
- UNIT_ASSERT(ToTitleRet(copy) == title);
- UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
- }
- {
- auto s = UTF8ToWide("Й");
- auto writableCopy = s;
- const auto copy = s;
- const auto title = UTF8ToWide("Й");
-
- UNIT_ASSERT(!ToTitle(s));
- UNIT_ASSERT(s == title);
+
+ UNIT_ASSERT(ToTitleRet(copy) == title);
+ UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
+ }
+ {
+ auto s = UTF8ToWide("й");
+ auto writableCopy = s;
+ const auto copy = s;
+ const auto title = UTF8ToWide("Й");
+
+ UNIT_ASSERT(ToTitle(s));
+ UNIT_ASSERT(s == title);
+
+ UNIT_ASSERT(ToTitle(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == title);
+
+ UNIT_ASSERT(ToTitle(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == title);
+
+ UNIT_ASSERT(ToTitleRet(copy) == title);
+ UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
+ }
+ {
+ auto s = UTF8ToWide("Й");
+ auto writableCopy = s;
+ const auto copy = s;
+ const auto title = UTF8ToWide("Й");
+
+ UNIT_ASSERT(!ToTitle(s));
+ UNIT_ASSERT(s == title);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == title);
-
- UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == title);
-
- UNIT_ASSERT(ToTitleRet(copy) == title);
- UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
- }
- {
- auto s = UTF8ToWide("тест");
- auto writableCopy = s;
- const auto copy = s;
- const auto title = UTF8ToWide("Тест");
-
- UNIT_ASSERT(ToTitle(s));
- UNIT_ASSERT(s == title);
-
- UNIT_ASSERT(ToTitle(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == title);
-
- UNIT_ASSERT(ToTitle(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == title);
-
- UNIT_ASSERT(ToTitleRet(copy) == title);
- UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
- }
- {
- auto s = UTF8ToWide("Тест");
- auto writableCopy = s;
- const auto copy = s;
- const auto title = UTF8ToWide("Тест");
-
- UNIT_ASSERT(!ToTitle(s));
- UNIT_ASSERT(s == title);
+
+ UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == title);
+
+ UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == title);
+
+ UNIT_ASSERT(ToTitleRet(copy) == title);
+ UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
+ }
+ {
+ auto s = UTF8ToWide("тест");
+ auto writableCopy = s;
+ const auto copy = s;
+ const auto title = UTF8ToWide("Тест");
+
+ UNIT_ASSERT(ToTitle(s));
+ UNIT_ASSERT(s == title);
+
+ UNIT_ASSERT(ToTitle(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == title);
+
+ UNIT_ASSERT(ToTitle(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == title);
+
+ UNIT_ASSERT(ToTitleRet(copy) == title);
+ UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
+ }
+ {
+ auto s = UTF8ToWide("Тест");
+ auto writableCopy = s;
+ const auto copy = s;
+ const auto title = UTF8ToWide("Тест");
+
+ UNIT_ASSERT(!ToTitle(s));
+ UNIT_ASSERT(s == title);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == title);
-
- UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == title);
-
- UNIT_ASSERT(ToTitleRet(copy) == title);
- UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
- }
- {
- auto s = UTF8ToWide("тЕст");
- auto writableCopy = s;
- const auto copy = s;
- const auto title = UTF8ToWide("Тест");
-
- UNIT_ASSERT(ToTitle(s));
- UNIT_ASSERT(s == title);
-
- UNIT_ASSERT(ToTitle(writableCopy.Detach(), writableCopy.size()));
- UNIT_ASSERT(writableCopy == title);
-
- UNIT_ASSERT(ToTitle(copy.data(), copy.size(), writableCopy.Detach()));
- UNIT_ASSERT(writableCopy == title);
-
- UNIT_ASSERT(ToTitleRet(copy) == title);
- UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
- }
- {
- auto s = UTF8ToWide("тЕст");
- const auto copy = s;
- const auto title = UTF8ToWide("тЕСт");
-
- UNIT_ASSERT(ToTitle(s, 2));
- UNIT_ASSERT(s == title);
-
- UNIT_ASSERT(ToTitleRet(copy, 2) == title);
- UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 2) == title);
- }
- {
- auto s = UTF8ToWide("теСт");
- const auto copy = s;
- const auto title = UTF8ToWide("теСт");
-
- UNIT_ASSERT(!ToTitle(s, 2));
- UNIT_ASSERT(s == title);
+
+ UNIT_ASSERT(!ToTitle(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == title);
+
+ UNIT_ASSERT(!ToTitle(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == title);
+
+ UNIT_ASSERT(ToTitleRet(copy) == title);
+ UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
+ }
+ {
+ auto s = UTF8ToWide("тЕст");
+ auto writableCopy = s;
+ const auto copy = s;
+ const auto title = UTF8ToWide("Тест");
+
+ UNIT_ASSERT(ToTitle(s));
+ UNIT_ASSERT(s == title);
+
+ UNIT_ASSERT(ToTitle(writableCopy.Detach(), writableCopy.size()));
+ UNIT_ASSERT(writableCopy == title);
+
+ UNIT_ASSERT(ToTitle(copy.data(), copy.size(), writableCopy.Detach()));
+ UNIT_ASSERT(writableCopy == title);
+
+ UNIT_ASSERT(ToTitleRet(copy) == title);
+ UNIT_ASSERT(ToTitleRet(TWtringBuf(copy)) == title);
+ }
+ {
+ auto s = UTF8ToWide("тЕст");
+ const auto copy = s;
+ const auto title = UTF8ToWide("тЕСт");
+
+ UNIT_ASSERT(ToTitle(s, 2));
+ UNIT_ASSERT(s == title);
+
+ UNIT_ASSERT(ToTitleRet(copy, 2) == title);
+ UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 2) == title);
+ }
+ {
+ auto s = UTF8ToWide("теСт");
+ const auto copy = s;
+ const auto title = UTF8ToWide("теСт");
+
+ UNIT_ASSERT(!ToTitle(s, 2));
+ UNIT_ASSERT(s == title);
#ifndef TSTRING_IS_STD_STRING
- UNIT_ASSERT(s.data() == copy.data());
+ UNIT_ASSERT(s.data() == copy.data());
#endif
-
- UNIT_ASSERT(ToTitleRet(copy, 2) == title);
- UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 2) == title);
- }
- {
- auto s = UTF8ToWide("теСт");
- const auto copy = s;
- const auto title = UTF8ToWide("теСТ");
-
- UNIT_ASSERT(ToTitle(s, 3, 1));
- UNIT_ASSERT(s == title);
-
- UNIT_ASSERT(ToTitleRet(copy, 3, 1) == title);
- UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 3, 1) == title);
- }
- {
- auto s = UTF8ToWide("теСт");
- const auto copy = s;
+
+ UNIT_ASSERT(ToTitleRet(copy, 2) == title);
+ UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 2) == title);
+ }
+ {
+ auto s = UTF8ToWide("теСт");
+ const auto copy = s;
+ const auto title = UTF8ToWide("теСТ");
+
+ UNIT_ASSERT(ToTitle(s, 3, 1));
+ UNIT_ASSERT(s == title);
+
+ UNIT_ASSERT(ToTitleRet(copy, 3, 1) == title);
+ UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 3, 1) == title);
+ }
+ {
+ auto s = UTF8ToWide("теСт");
+ const auto copy = s;
const auto title = UTF8ToWide("теСТ");
-
- UNIT_ASSERT(ToTitle(s, 3, 100500));
- UNIT_ASSERT(s == title);
-
- UNIT_ASSERT(ToTitleRet(copy, 3, 100500) == title);
- UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 3, 100500) == title);
- }
- }
+
+ UNIT_ASSERT(ToTitle(s, 3, 100500));
+ UNIT_ASSERT(s == title);
+
+ UNIT_ASSERT(ToTitleRet(copy, 3, 100500) == title);
+ UNIT_ASSERT(ToTitleRet(TWtringBuf(copy), 3, 100500) == title);
+ }
+ }
};
UNIT_TEST_SUITE_REGISTRATION(TWideUtilTest);
diff --git a/util/datetime/base.cpp b/util/datetime/base.cpp
index 39c49b7133..38ecc3ab96 100644
--- a/util/datetime/base.cpp
+++ b/util/datetime/base.cpp
@@ -42,7 +42,7 @@ namespace {
return {i};
}
- inline IOutputStream& operator<<(IOutputStream& o, const TPad<2>& p) {
+ inline IOutputStream& operator<<(IOutputStream& o, const TPad<2>& p) {
if (p.I < 10) {
if (p.I >= 0) {
o << '0';
@@ -52,7 +52,7 @@ namespace {
return o << p.I;
}
- inline IOutputStream& operator<<(IOutputStream& o, const TPad<4>& p) {
+ inline IOutputStream& operator<<(IOutputStream& o, const TPad<4>& p) {
if (p.I < 1000) {
if (p.I >= 0) {
if (p.I < 10) {
@@ -68,7 +68,7 @@ namespace {
return o << p.I;
}
- inline IOutputStream& operator<<(IOutputStream& o, const TPad<6>& p) {
+ inline IOutputStream& operator<<(IOutputStream& o, const TPad<6>& p) {
if (p.I < 100000) {
if (p.I >= 0) {
if (p.I < 10) {
@@ -88,11 +88,11 @@ namespace {
return o << p.I;
}
- void WriteMicroSecondsToStream(IOutputStream& os, ui32 microSeconds) {
+ void WriteMicroSecondsToStream(IOutputStream& os, ui32 microSeconds) {
os << '.' << Pad<6>(microSeconds);
}
- void WriteTmToStream(IOutputStream& os, const struct tm& theTm) {
+ void WriteTmToStream(IOutputStream& os, const struct tm& theTm) {
os << Pad<4>(theTm.tm_year + 1900) << '-' << Pad<2>(theTm.tm_mon + 1) << '-' << Pad<2>(theTm.tm_mday) << 'T'
<< Pad<2>(theTm.tm_hour) << ':' << Pad<2>(theTm.tm_min) << ':' << Pad<2>(theTm.tm_sec);
}
@@ -134,20 +134,20 @@ namespace {
}
template <>
-void Out<TDuration>(IOutputStream& os, TTypeTraits<TDuration>::TFuncParam duration) {
+void Out<TDuration>(IOutputStream& os, TTypeTraits<TDuration>::TFuncParam duration) {
os << duration.Seconds();
WriteMicroSecondsToStream(os, duration.MicroSecondsOfSecond());
os << 's';
}
template <>
-void Out<TInstant>(IOutputStream& os, TTypeTraits<TInstant>::TFuncParam instant) {
+void Out<TInstant>(IOutputStream& os, TTypeTraits<TInstant>::TFuncParam instant) {
char buf[64];
auto len = FormatDate8601(buf, sizeof(buf), instant.TimeT());
-
+
// shouldn't happen due to current implementation of FormatDate8601() and GmTimeR()
Y_ENSURE(len, TStringBuf("Out<TInstant>: year does not fit into an integer"));
-
+
os.Write(buf, len - 1 /* 'Z' */);
WriteMicroSecondsToStream(os, instant.MicroSecondsOfSecond());
os << 'Z';
diff --git a/util/datetime/base.h b/util/datetime/base.h
index 11666de71e..5e902b8f63 100644
--- a/util/datetime/base.h
+++ b/util/datetime/base.h
@@ -49,7 +49,7 @@ constexpr long seconds(const struct tm& theTm) {
return 60 * (60 * theTm.tm_hour + theTm.tm_min) + theTm.tm_sec;
}
-void sprint_gm_date(char* buf, time_t when, long* sec = nullptr);
+void sprint_gm_date(char* buf, time_t when, long* sec = nullptr);
bool sscan_date(const char* date, struct tm& theTm);
const int DATE_8601_LEN = 21; // strlen("YYYY-MM-DDThh:mm:ssZ") = 20 + '\0'
@@ -120,7 +120,7 @@ public:
}
constexpr double SecondsFloat() const noexcept {
- return Value_ * (1 / 1000000.0);
+ return Value_ * (1 / 1000000.0);
}
constexpr double MillisecondsFloat() const noexcept {
@@ -152,7 +152,7 @@ public:
}
constexpr TValue NanoSeconds() const noexcept {
- return MicroSeconds() >= (Max<TValue>() / (TValue)1000) ? Max<TValue>() : MicroSeconds() * (TValue)1000;
+ return MicroSeconds() >= (Max<TValue>() / (TValue)1000) ? Max<TValue>() : MicroSeconds() * (TValue)1000;
}
constexpr ui32 MicroSecondsOfSecond() const noexcept {
@@ -308,11 +308,11 @@ public:
}
/// parses strings like 10s, 15ms, 15.05s, 20us, or just 25 (s). See parser_ut.cpp for details
- static TDuration Parse(const TStringBuf input);
+ static TDuration Parse(const TStringBuf input);
- static bool TryParse(const TStringBuf input, TDuration& result);
+ static bool TryParse(const TStringBuf input, TDuration& result);
- // note global Out method is defined for TDuration, so it could be written to IOutputStream as text
+ // note global Out method is defined for TDuration, so it could be written to IOutputStream as text
template <class T>
inline TDuration& operator+=(const T& t) noexcept {
@@ -337,7 +337,7 @@ public:
TString ToString() const;
};
-Y_DECLARE_PODTYPE(TDuration);
+Y_DECLARE_PODTYPE(TDuration);
template <>
struct THash<TDuration> {
@@ -447,7 +447,7 @@ public:
* Formats the instant using the UTC time zone, with microsecond precision.
*
* @returns An ISO 8601 formatted string, e.g. '2015-11-21T23:30:27.991669Z'.
- * @note Global Out method is defined to TInstant, so it can be written as text to IOutputStream.
+ * @note Global Out method is defined to TInstant, so it can be written as text to IOutputStream.
*/
TString ToString() const;
@@ -507,45 +507,45 @@ public:
TString FormatLocalTime(const char* format) const noexcept;
TString FormatGmTime(const char* format) const noexcept;
- /// See #TryParseIso8601.
- static TInstant ParseIso8601(TStringBuf);
- /// See #TryParseRfc822.
+ /// See #TryParseIso8601.
+ static TInstant ParseIso8601(TStringBuf);
+ /// See #TryParseRfc822.
static TInstant ParseRfc822(TStringBuf);
- /// See #TryParseHttp.
- static TInstant ParseHttp(TStringBuf);
- /// See #TryParseX509.
- static TInstant ParseX509Validity(TStringBuf);
-
- /// ISO 8601 Representation of Dates and Times
- ///
- /// @link https://www.iso.org/standard/40874.html Description of format.
- static bool TryParseIso8601(TStringBuf input, TInstant& instant);
-
- /// RFC 822 Date and Time specification
- ///
- /// @link https://tools.ietf.org/html/rfc822#section-5 Description of format.
- static bool TryParseRfc822(TStringBuf input, TInstant& instant);
-
- /// RFC 2616 3.3.1 Full Date
- ///
- /// @link https://tools.ietf.org/html/rfc2616#section-3.3.1 Description of format.
- static bool TryParseHttp(TStringBuf input, TInstant& instant);
-
- /// X.509 certificate validity time (see rfc5280 4.1.2.5.*)
- ///
- /// @link https://tools.ietf.org/html/rfc5280#section-4.1.2.5 Description of format.
- static bool TryParseX509(TStringBuf input, TInstant& instant);
-
- static TInstant ParseIso8601Deprecated(TStringBuf);
- static TInstant ParseRfc822Deprecated(TStringBuf);
- static TInstant ParseHttpDeprecated(TStringBuf);
- static TInstant ParseX509ValidityDeprecated(TStringBuf);
-
- static bool TryParseIso8601Deprecated(TStringBuf input, TInstant& instant);
- static bool TryParseRfc822Deprecated(TStringBuf input, TInstant& instant);
- static bool TryParseHttpDeprecated(TStringBuf input, TInstant& instant);
- static bool TryParseX509Deprecated(TStringBuf input, TInstant& instant);
-
+ /// See #TryParseHttp.
+ static TInstant ParseHttp(TStringBuf);
+ /// See #TryParseX509.
+ static TInstant ParseX509Validity(TStringBuf);
+
+ /// ISO 8601 Representation of Dates and Times
+ ///
+ /// @link https://www.iso.org/standard/40874.html Description of format.
+ static bool TryParseIso8601(TStringBuf input, TInstant& instant);
+
+ /// RFC 822 Date and Time specification
+ ///
+ /// @link https://tools.ietf.org/html/rfc822#section-5 Description of format.
+ static bool TryParseRfc822(TStringBuf input, TInstant& instant);
+
+ /// RFC 2616 3.3.1 Full Date
+ ///
+ /// @link https://tools.ietf.org/html/rfc2616#section-3.3.1 Description of format.
+ static bool TryParseHttp(TStringBuf input, TInstant& instant);
+
+ /// X.509 certificate validity time (see rfc5280 4.1.2.5.*)
+ ///
+ /// @link https://tools.ietf.org/html/rfc5280#section-4.1.2.5 Description of format.
+ static bool TryParseX509(TStringBuf input, TInstant& instant);
+
+ static TInstant ParseIso8601Deprecated(TStringBuf);
+ static TInstant ParseRfc822Deprecated(TStringBuf);
+ static TInstant ParseHttpDeprecated(TStringBuf);
+ static TInstant ParseX509ValidityDeprecated(TStringBuf);
+
+ static bool TryParseIso8601Deprecated(TStringBuf input, TInstant& instant);
+ static bool TryParseRfc822Deprecated(TStringBuf input, TInstant& instant);
+ static bool TryParseHttpDeprecated(TStringBuf input, TInstant& instant);
+ static bool TryParseX509Deprecated(TStringBuf input, TInstant& instant);
+
template <class T>
inline TInstant& operator+=(const T& t) noexcept {
return (*this = (*this + t));
@@ -557,7 +557,7 @@ public:
}
};
-Y_DECLARE_PODTYPE(TInstant);
+Y_DECLARE_PODTYPE(TInstant);
template <>
struct THash<TInstant> {
@@ -578,9 +578,9 @@ namespace NPrivate {
};
}
-/** @name Helpers for printing local times to `IOutputStream`s.
+/** @name Helpers for printing local times to `IOutputStream`s.
* The FormatLocal* functions create an opaque object that, when written to
- * a `IOutputStream`, outputs this instant as an ISO 8601 formatted string
+ * a `IOutputStream`, outputs this instant as an ISO 8601 formatted string
* using the system time zone.
*
* @note The only reason behind this set of functions is to avoid excessive
@@ -634,14 +634,14 @@ static constexpr bool operator>=(const TTimeBase<S>& l, const TTimeBase<S>& r) n
namespace NDateTimeHelpers {
template <typename T>
static constexpr T SumWithSaturation(T a, T b) {
- static_assert(!std::numeric_limits<T>::is_signed, "expect !std::numeric_limits<T>::is_signed");
+ static_assert(!std::numeric_limits<T>::is_signed, "expect !std::numeric_limits<T>::is_signed");
return Max<T>() - a < b ? Max<T>() : a + b;
}
template <typename T>
static constexpr T DiffWithSaturation(T a, T b) {
- static_assert(!std::numeric_limits<T>::is_signed, "expect !std::numeric_limits<T>::is_signed");
+ static_assert(!std::numeric_limits<T>::is_signed, "expect !std::numeric_limits<T>::is_signed");
return a < b ? 0 : a - b;
}
@@ -773,8 +773,8 @@ constexpr TInstant operator-(const TInstant& l, const std::chrono::duration<T, T
template <class T>
inline TDuration operator*(TDuration d, T t) noexcept {
- Y_ASSERT(t >= T());
- Y_ASSERT(t == T() || Max<TDuration::TValue>() / t >= d.GetValue());
+ Y_ASSERT(t >= T());
+ Y_ASSERT(t == T() || Max<TDuration::TValue>() / t >= d.GetValue());
return TDuration::FromValue(d.GetValue() * t);
}
@@ -794,7 +794,7 @@ inline TDuration operator*(T t, TDuration d) noexcept {
return d * t;
}
-template <class T, std::enable_if_t<!std::is_same<TDuration, T>::value, int> = 0>
+template <class T, std::enable_if_t<!std::is_same<TDuration, T>::value, int> = 0>
constexpr TDuration operator/(const TDuration& d, const T& t) noexcept {
return TDuration::FromValue(d.GetValue() / t);
}
diff --git a/util/datetime/base_ut.cpp b/util/datetime/base_ut.cpp
index 605bcfd452..afc3f802eb 100644
--- a/util/datetime/base_ut.cpp
+++ b/util/datetime/base_ut.cpp
@@ -47,8 +47,8 @@ namespace {
}
}
-Y_UNIT_TEST_SUITE(TestSprintDate) {
- Y_UNIT_TEST(Year9999) {
+Y_UNIT_TEST_SUITE(TestSprintDate) {
+ Y_UNIT_TEST(Year9999) {
struct tm t;
t.tm_year = 9999 - 1900;
t.tm_mday = 1;
@@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(TestSprintDate) {
UNIT_ASSERT_VALUES_EQUAL(expectedDate, ToString(buf));
}
- Y_UNIT_TEST(YearAfter9999) {
+ Y_UNIT_TEST(YearAfter9999) {
struct tm t;
t.tm_year = 123456 - 1900;
t.tm_mday = 1;
@@ -70,7 +70,7 @@ Y_UNIT_TEST_SUITE(TestSprintDate) {
char buf[DATE_BUF_LEN];
UNIT_ASSERT_EXCEPTION(DateToString(buf, t), yexception);
}
- Y_UNIT_TEST(SmallYear) {
+ Y_UNIT_TEST(SmallYear) {
struct tm t;
t.tm_year = 0 - 1900;
t.tm_mday = 1;
@@ -83,7 +83,7 @@ Y_UNIT_TEST_SUITE(TestSprintDate) {
UNIT_ASSERT_VALUES_EQUAL(expectedDate, ToString(buf));
}
- Y_UNIT_TEST(SmallYearAndMonth) {
+ Y_UNIT_TEST(SmallYearAndMonth) {
struct tm t;
t.tm_year = 99 - 1900;
t.tm_mday = 1;
@@ -338,18 +338,18 @@ Y_UNIT_TEST_SUITE(TDateTimeTest) {
}
}
-Y_UNIT_TEST_SUITE(DateTimeTest) {
- Y_UNIT_TEST(TestDurationFromFloat) {
+Y_UNIT_TEST_SUITE(DateTimeTest) {
+ Y_UNIT_TEST(TestDurationFromFloat) {
UNIT_ASSERT_EQUAL(TDuration::MilliSeconds(500), TDuration::Seconds(0.5));
UNIT_ASSERT_EQUAL(TDuration::MilliSeconds(500), TDuration::Seconds(0.5f));
}
- Y_UNIT_TEST(TestSecondsLargeValue) {
+ Y_UNIT_TEST(TestSecondsLargeValue) {
unsigned int seconds = UINT_MAX;
UNIT_ASSERT_VALUES_EQUAL(((ui64)seconds) * 1000000, TDuration::Seconds(seconds).MicroSeconds());
}
- Y_UNIT_TEST(TestToString) {
+ Y_UNIT_TEST(TestToString) {
#define CHECK_CONVERTIBLE(v) \
do { \
UNIT_ASSERT_VALUES_EQUAL(v, ToString(TDuration::Parse(v))); \
@@ -371,7 +371,7 @@ Y_UNIT_TEST_SUITE(DateTimeTest) {
CHECK_CONVERTIBLE("33.011122s");
}
- Y_UNIT_TEST(TestFromString) {
+ Y_UNIT_TEST(TestFromString) {
static const struct T {
const char* const Str;
const TDuration::TValue MicroSeconds;
@@ -384,7 +384,7 @@ Y_UNIT_TEST_SUITE(DateTimeTest) {
{"x3ms", 0, false},
};
- for (const T* t = tests; t != std::end(tests); ++t) {
+ for (const T* t = tests; t != std::end(tests); ++t) {
// FromString
bool parsed = false;
try {
@@ -403,14 +403,14 @@ Y_UNIT_TEST_SUITE(DateTimeTest) {
}
}
- Y_UNIT_TEST(TestSleep) {
+ Y_UNIT_TEST(TestSleep) {
// check does not throw
Sleep(TDuration::Seconds(0));
Sleep(TDuration::MicroSeconds(1));
Sleep(TDuration::MilliSeconds(1));
}
- Y_UNIT_TEST(TestInstantToString) {
+ Y_UNIT_TEST(TestInstantToString) {
UNIT_ASSERT_VALUES_EQUAL(TString("2009-08-06T15:19:06.023455Z"), ToString(TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)));
UNIT_ASSERT_VALUES_EQUAL(TString("2009-08-06T15:19:06.023455Z"), (TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)).ToString());
UNIT_ASSERT_VALUES_EQUAL(TString("2009-08-06T15:19:06Z"), (TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)).ToStringUpToSeconds());
@@ -420,7 +420,7 @@ Y_UNIT_TEST_SUITE(DateTimeTest) {
UNIT_ASSERT_VALUES_EQUAL(TString("Thu, 06 Aug 2009 15:19:06 GMT"), (TInstant::Seconds(1249571946) + TDuration::MicroSeconds(23455)).ToRfc822String());
}
- Y_UNIT_TEST(TestInstantMath) {
+ Y_UNIT_TEST(TestInstantMath) {
UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(1719), TInstant::Seconds(1700) + TDuration::Seconds(19));
// overflow
UNIT_ASSERT_VALUES_EQUAL(TInstant::Max(), TInstant::Max() - TDuration::Seconds(10) + TDuration::Seconds(19));
@@ -429,7 +429,7 @@ Y_UNIT_TEST_SUITE(DateTimeTest) {
UNIT_ASSERT_VALUES_EQUAL(TDuration::Zero(), TInstant::Seconds(1000) - TInstant::Seconds(2000));
}
- Y_UNIT_TEST(TestDurationMath) {
+ Y_UNIT_TEST(TestDurationMath) {
TDuration empty;
UNIT_ASSERT(!empty);
// ensure that this compiles too
@@ -484,20 +484,20 @@ Y_UNIT_TEST_SUITE(DateTimeTest) {
UNIT_ASSERT_VALUES_EQUAL(onlyDays.Days(), days);
}
- Y_UNIT_TEST(TestInstantUnits) {
+ Y_UNIT_TEST(TestInstantUnits) {
TestTimeUnits<TInstant>();
}
- Y_UNIT_TEST(TestDurationUnits) {
+ Y_UNIT_TEST(TestDurationUnits) {
TestTimeUnits<TDuration>();
}
- Y_UNIT_TEST(TestNoexceptConstruction) {
+ Y_UNIT_TEST(TestNoexceptConstruction) {
UNIT_ASSERT_EXCEPTION(TDuration::MilliSeconds(FromString(TStringBuf("not a number"))), yexception);
UNIT_ASSERT_EXCEPTION(TDuration::Seconds(FromString(TStringBuf("not a number"))), yexception);
}
- Y_UNIT_TEST(TestFromValueForTDuration) {
+ Y_UNIT_TEST(TestFromValueForTDuration) {
// check that FromValue creates the same TDuration
TDuration d1 = TDuration::MicroSeconds(12345);
TDuration d2 = TDuration::FromValue(d1.GetValue());
@@ -505,7 +505,7 @@ Y_UNIT_TEST_SUITE(DateTimeTest) {
UNIT_ASSERT_VALUES_EQUAL(d1, d2);
}
- Y_UNIT_TEST(TestFromValueForTInstant) {
+ Y_UNIT_TEST(TestFromValueForTInstant) {
// check that FromValue creates the same TInstant
TInstant i1 = TInstant::MicroSeconds(12345);
TInstant i2 = TInstant::FromValue(i1.GetValue());
diff --git a/util/datetime/cputimer.cpp b/util/datetime/cputimer.cpp
index 978d41254e..516d372c37 100644
--- a/util/datetime/cputimer.cpp
+++ b/util/datetime/cputimer.cpp
@@ -2,7 +2,7 @@
#include <util/system/defaults.h>
#include <util/system/hp_timer.h>
-#include <util/string/printf.h>
+#include <util/string/printf.h>
#include <util/stream/output.h>
#include <util/generic/singleton.h>
@@ -16,7 +16,7 @@
#include <util/system/winint.h>
#endif
-TTimer::TTimer(const TStringBuf message) {
+TTimer::TTimer(const TStringBuf message) {
static const int SMALL_DURATION_CHAR_LENGTH = 9; // strlen("0.123456s")
Message_.Reserve(message.length() + SMALL_DURATION_CHAR_LENGTH + 1); // +"\n"
Message_ << message;
@@ -77,7 +77,7 @@ TString FormatCycles(ui64 cycles) {
return result;
}
-TFormattedPrecisionTimer::TFormattedPrecisionTimer(const char* message, IOutputStream* out)
+TFormattedPrecisionTimer::TFormattedPrecisionTimer(const char* message, IOutputStream* out)
: Message(message)
, Out(out)
{
@@ -106,7 +106,7 @@ TTimeLogger::TTimeLogger(const TString& message, bool verbose)
: Message(message)
, Verbose(verbose)
, OK(false)
- , Begin(time(nullptr))
+ , Begin(time(nullptr))
, BeginCycles(GetCycleCount())
{
if (Verbose) {
@@ -116,7 +116,7 @@ TTimeLogger::TTimeLogger(const TString& message, bool verbose)
}
double TTimeLogger::ElapsedTime() const {
- return time(nullptr) - Begin;
+ return time(nullptr) - Begin;
}
void TTimeLogger::SetOK() {
@@ -124,7 +124,7 @@ void TTimeLogger::SetOK() {
}
TTimeLogger::~TTimeLogger() {
- time_t tim = time(nullptr);
+ time_t tim = time(nullptr);
ui64 endCycles = GetCycleCount();
if (Verbose) {
const char* prefix = (OK) ? "" : "!";
diff --git a/util/datetime/cputimer.h b/util/datetime/cputimer.h
index 6104240264..7d38d5bdb3 100644
--- a/util/datetime/cputimer.h
+++ b/util/datetime/cputimer.h
@@ -78,10 +78,10 @@ class TFormattedPrecisionTimer {
private:
ui64 Start;
const char* Message;
- IOutputStream* Out;
+ IOutputStream* Out;
public:
- TFormattedPrecisionTimer(const char* message = "took ", IOutputStream* out = &Cout);
+ TFormattedPrecisionTimer(const char* message = "took ", IOutputStream* out = &Cout);
~TFormattedPrecisionTimer();
};
diff --git a/util/datetime/parser.rl6 b/util/datetime/parser.rl6
index 184b646a2d..931f09eae1 100644
--- a/util/datetime/parser.rl6
+++ b/util/datetime/parser.rl6
@@ -395,27 +395,27 @@ bool TX509Validity4yDateTimeParser::ParsePart(const char *input, size_t len) {
}
TInstant TIso8601DateTimeParserDeprecated::GetResult(TInstant defaultValue) const {
- Y_UNUSED(ISO8601DateTimeParser_en_main);
+ Y_UNUSED(ISO8601DateTimeParser_en_main);
return TDateTimeParserBaseDeprecated::GetResult(ISO8601DateTimeParser_first_final, defaultValue);
}
TInstant TRfc822DateTimeParserDeprecated::GetResult(TInstant defaultValue) const {
- Y_UNUSED(RFC822DateParser_en_main);
+ Y_UNUSED(RFC822DateParser_en_main);
return TDateTimeParserBaseDeprecated::GetResult(RFC822DateParser_first_final, defaultValue);
}
TInstant THttpDateTimeParserDeprecated::GetResult(TInstant defaultValue) const {
- Y_UNUSED(HttpDateTimeParserStandalone_en_main);
+ Y_UNUSED(HttpDateTimeParserStandalone_en_main);
return TDateTimeParserBaseDeprecated::GetResult(HttpDateTimeParserStandalone_first_final, defaultValue);
}
TInstant TX509ValidityDateTimeParserDeprecated::GetResult(TInstant defaultValue) const {
- Y_UNUSED(X509ValidityDateTimeParser_en_main);
+ Y_UNUSED(X509ValidityDateTimeParser_en_main);
return TDateTimeParserBaseDeprecated::GetResult(X509ValidityDateTimeParser_first_final, defaultValue);
}
TInstant TX509Validity4yDateTimeParserDeprecated::GetResult(TInstant defaultValue) const {
- Y_UNUSED(X509Validity4yDateTimeParser_en_main);
+ Y_UNUSED(X509Validity4yDateTimeParser_en_main);
return TDateTimeParserBaseDeprecated::GetResult(X509Validity4yDateTimeParser_first_final, defaultValue);
}
@@ -452,10 +452,10 @@ static inline TResult Parse(const char* input, size_t len, TResult defaultValue)
return parser.GetResult(defaultValue);
}
-template<class TParser, class TResult, bool ThrowExceptionOnFailure = true>
+template<class TParser, class TResult, bool ThrowExceptionOnFailure = true>
static inline TResult ParseUnsafe(const char* input, size_t len) {
TResult r = Parse<TParser, TResult>(input, len, TResult::Max());
- if (ThrowExceptionOnFailure && r == TResult::Max())
+ if (ThrowExceptionOnFailure && r == TResult::Max())
ythrow TDateTimeParseException() << "error in datetime parsing. Input data: " << TStringBuf(input, len);
return r;
}
@@ -479,56 +479,56 @@ TInstant TInstant::ParseX509ValidityDeprecated(const TStringBuf input) {
case 15:
return ParseUnsafe<TX509Validity4yDateTimeParserDeprecated, TInstant>(input.data(), 15);
default:
- ythrow TDateTimeParseException();
+ ythrow TDateTimeParseException();
}
}
bool TInstant::TryParseIso8601Deprecated(const TStringBuf input, TInstant& instant) {
const auto parsed = ParseUnsafe<TIso8601DateTimeParserDeprecated, TInstant, false>(input.data(), input.size());
- if (TInstant::Max() == parsed) {
- return false;
- }
- instant = parsed;
- return true;
-}
+ if (TInstant::Max() == parsed) {
+ return false;
+ }
+ instant = parsed;
+ return true;
+}
bool TInstant::TryParseRfc822Deprecated(const TStringBuf input, TInstant& instant) {
const auto parsed = ParseUnsafe<TRfc822DateTimeParserDeprecated, TInstant, false>(input.data(), input.size());
- if (TInstant::Max() == parsed) {
- return false;
- }
- instant = parsed;
- return true;
-}
-
+ if (TInstant::Max() == parsed) {
+ return false;
+ }
+ instant = parsed;
+ return true;
+}
+
bool TInstant::TryParseHttpDeprecated(const TStringBuf input, TInstant& instant) {
const auto parsed = ParseUnsafe<THttpDateTimeParserDeprecated, TInstant, false>(input.data(), input.size());
- if (TInstant::Max() == parsed) {
- return false;
- }
- instant = parsed;
- return true;
-}
-
+ if (TInstant::Max() == parsed) {
+ return false;
+ }
+ instant = parsed;
+ return true;
+}
+
bool TInstant::TryParseX509Deprecated(const TStringBuf input, TInstant& instant) {
- TInstant parsed;
+ TInstant parsed;
switch (input.size()) {
- case 13:
+ case 13:
parsed = ParseUnsafe<TX509ValidityDateTimeParserDeprecated, TInstant, false>(input.data(), 13);
- break;
- case 15:
+ break;
+ case 15:
parsed = ParseUnsafe<TX509Validity4yDateTimeParserDeprecated, TInstant, false>(input.data(), 15);
- break;
- default:
- return false;
- }
- if (TInstant::Max() == parsed) {
- return false;
- }
- instant = parsed;
- return true;
-}
-
+ break;
+ default:
+ return false;
+ }
+ if (TInstant::Max() == parsed) {
+ return false;
+ }
+ instant = parsed;
+ return true;
+}
+
TInstant TInstant::ParseIso8601(const TStringBuf input) {
return ParseUnsafe<TIso8601DateTimeParser, TInstant>(input.data(), input.size());
}
@@ -761,7 +761,7 @@ TDurationParser::TDurationParser()
, FractionPart(0)
, FractionDigits(0)
{
- Y_UNUSED(TDurationParser_en_main);
+ Y_UNUSED(TDurationParser_en_main);
%% write init;
}
@@ -788,7 +788,7 @@ TDuration TDurationParser::GetResult(TDuration defaultValue) const {
return TDuration::MicroSeconds(us);
}
-bool TDuration::TryParse(const TStringBuf input, TDuration& result) {
+bool TDuration::TryParse(const TStringBuf input, TDuration& result) {
TDuration r = ::Parse<TDurationParser, TDuration>(input.data(), input.size(), TDuration::Max());
if (r == TDuration::Max())
return false;
@@ -796,6 +796,6 @@ bool TDuration::TryParse(const TStringBuf input, TDuration& result) {
return true;
}
-TDuration TDuration::Parse(const TStringBuf input) {
+TDuration TDuration::Parse(const TStringBuf input) {
return ParseUnsafe<TDurationParser, TDuration>(input.data(), input.size());
}
diff --git a/util/datetime/parser_ut.cpp b/util/datetime/parser_ut.cpp
index 44834bd0ef..61364af997 100644
--- a/util/datetime/parser_ut.cpp
+++ b/util/datetime/parser_ut.cpp
@@ -5,8 +5,8 @@
static const time_t SECONDS_PER_HOUR = 3600;
static const time_t SECONDS_PER_MINUTE = 60;
-Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
- Y_UNIT_TEST(TestRfc822Correct) {
+Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
+ Y_UNIT_TEST(TestRfc822Correct) {
bool r = false;
time_t t = 0;
@@ -159,14 +159,14 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
}
}
- Y_UNIT_TEST(TestRfc822MilitaryZones) {
+ Y_UNIT_TEST(TestRfc822MilitaryZones) {
DoTestMilitaryZones('A', 'I');
DoTestMilitaryZones('K', 'Z');
DoTestMilitaryZones('a', 'i');
DoTestMilitaryZones('k', 'z');
}
- Y_UNIT_TEST(TestRfc822IncorrectDates) {
+ Y_UNIT_TEST(TestRfc822IncorrectDates) {
bool r = true;
time_t t = 0;
@@ -255,7 +255,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
UNIT_ASSERT(!r);
}
- Y_UNIT_TEST(TestRfc822Partial) {
+ Y_UNIT_TEST(TestRfc822Partial) {
TRfc822DateTimeParser p;
const char* part1 = "Fri, 4 Mar 05 1";
const char* part2 = "9:34:45 +0300";
@@ -268,7 +268,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(1109954086), p.GetResult(TInstant::Zero()));
}
- Y_UNIT_TEST(TestIso8601Partial) {
+ Y_UNIT_TEST(TestIso8601Partial) {
TIso8601DateTimeParser p;
const char* part1 = "1990-03-15T15:1";
const char* part2 = "6:17+0732";
@@ -281,7 +281,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(637487058), p.GetResult(TInstant::Zero()));
}
- Y_UNIT_TEST(TestIso8601Correct) {
+ Y_UNIT_TEST(TestIso8601Correct) {
bool ret;
time_t t;
@@ -361,7 +361,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
UNIT_ASSERT_VALUES_EQUAL(t, 1269775620);
}
- Y_UNIT_TEST(TestIso8601TimeZone) {
+ Y_UNIT_TEST(TestIso8601TimeZone) {
time_t t1, t2, t3, t4;
UNIT_ASSERT(ParseISO8601DateTime("2010-03-28T04:27:00.000+07:00", t1));
UNIT_ASSERT(ParseISO8601DateTime("2010-03-27T21:27:00.000Z", t2));
@@ -372,7 +372,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
UNIT_ASSERT_VALUES_EQUAL(t3, t4);
}
- Y_UNIT_TEST(TestIso8601Incorrect) {
+ Y_UNIT_TEST(TestIso8601Incorrect) {
bool ret;
time_t t;
@@ -406,7 +406,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
UNIT_ASSERT(!ret);
}
- Y_UNIT_TEST(TestIso8601Fractions) {
+ Y_UNIT_TEST(TestIso8601Fractions) {
UNIT_ASSERT_VALUES_EQUAL(
TInstant::ParseIso8601("2009-09-19 03:37:08.1+04:00"),
TInstant::Seconds(1253317028) + TDuration::MilliSeconds(100));
@@ -471,7 +471,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
}
}
- Y_UNIT_TEST(TestHttpDate) {
+ Y_UNIT_TEST(TestHttpDate) {
UNIT_ASSERT_VALUES_EQUAL(
TInstant::ParseHttp("Sun, 06 Nov 1994 08:49:37 GMT"),
TInstant::ParseIso8601("1994-11-06T08:49:37Z"));
@@ -486,14 +486,14 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
TInstant::ParseIso8601("2037-01-19T08:49:37Z"));
}
- Y_UNIT_TEST(TestHttpDateIncorrect) {
+ Y_UNIT_TEST(TestHttpDateIncorrect) {
bool ret;
time_t t = 0;
ret = ParseHTTPDateTime("1990-03-15T15:16:17Z", t);
UNIT_ASSERT(!ret);
}
- Y_UNIT_TEST(TestX509ValidityTime) {
+ Y_UNIT_TEST(TestX509ValidityTime) {
UNIT_ASSERT_VALUES_EQUAL(
TInstant::ParseX509Validity("20091014165533Z"),
TInstant::ParseRfc822("Wed, 14 Oct 2009 16:55:33 GMT"));
@@ -505,7 +505,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
TInstant::ParseRfc822("31 Dec 2019 23:59:59 GMT"));
}
- Y_UNIT_TEST(TestX509ValidityTimeIncorrect) {
+ Y_UNIT_TEST(TestX509ValidityTimeIncorrect) {
bool ret;
time_t t = 0;
ret = ParseX509ValidityDateTime("500101000000Z", t);
@@ -513,65 +513,65 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
ret = ParseX509ValidityDateTime("091014165533+0300", t);
UNIT_ASSERT(!ret);
}
-
- Y_UNIT_TEST(TestTInstantTryParse) {
- {
+
+ Y_UNIT_TEST(TestTInstantTryParse) {
+ {
const TStringBuf s = "2009-09-19 03:37:08.1+04:00";
const auto i = TInstant::ParseIso8601(s);
- TInstant iTry;
+ TInstant iTry;
UNIT_ASSERT(TInstant::TryParseIso8601(s, iTry));
- UNIT_ASSERT_VALUES_EQUAL(i, iTry);
- }
- {
+ UNIT_ASSERT_VALUES_EQUAL(i, iTry);
+ }
+ {
const TStringBuf s = "2009-09aslkdjfkljasdjfl4:00";
- TInstant iTry;
+ TInstant iTry;
UNIT_ASSERT_EXCEPTION(TInstant::ParseIso8601(s), TDateTimeParseException);
UNIT_ASSERT(!TInstant::TryParseIso8601(s, iTry));
- }
- {
+ }
+ {
const TStringBuf s = "Wed, 14 Oct 2009 16:55:33 GMT";
const auto i = TInstant::ParseRfc822(s);
- TInstant iTry;
+ TInstant iTry;
UNIT_ASSERT(TInstant::TryParseRfc822(s, iTry));
- UNIT_ASSERT_VALUES_EQUAL(i, iTry);
- }
- {
+ UNIT_ASSERT_VALUES_EQUAL(i, iTry);
+ }
+ {
const TStringBuf s = "Wed, alsdjflkasjdfl:55:33 GMT";
- TInstant iTry;
+ TInstant iTry;
UNIT_ASSERT_EXCEPTION(TInstant::ParseRfc822(s), TDateTimeParseException);
UNIT_ASSERT(!TInstant::TryParseRfc822(s, iTry));
- }
- {
+ }
+ {
const TStringBuf s = "20091014165533Z";
const auto i = TInstant::ParseX509Validity(s);
- TInstant iTry;
+ TInstant iTry;
UNIT_ASSERT(TInstant::TryParseX509(s, iTry));
- UNIT_ASSERT_VALUES_EQUAL(i, iTry);
- }
- {
+ UNIT_ASSERT_VALUES_EQUAL(i, iTry);
+ }
+ {
const TStringBuf s = "200asdfasdf533Z";
- TInstant iTry;
+ TInstant iTry;
UNIT_ASSERT_EXCEPTION(TInstant::ParseX509Validity(s), TDateTimeParseException);
UNIT_ASSERT(!TInstant::TryParseX509(s, iTry));
- }
- {
+ }
+ {
const TStringBuf s = "990104074212Z";
const auto i = TInstant::ParseX509Validity(s);
- TInstant iTry;
+ TInstant iTry;
UNIT_ASSERT(TInstant::TryParseX509(s, iTry));
- UNIT_ASSERT_VALUES_EQUAL(i, iTry);
- }
- {
+ UNIT_ASSERT_VALUES_EQUAL(i, iTry);
+ }
+ {
const TStringBuf s = "9901asdf4212Z";
- TInstant iTry;
+ TInstant iTry;
UNIT_ASSERT_EXCEPTION(TInstant::ParseX509Validity(s), TDateTimeParseException);
UNIT_ASSERT(!TInstant::TryParseX509(s, iTry));
- }
- }
+ }
+ }
}
-Y_UNIT_TEST_SUITE(TDurationParseTest) {
- Y_UNIT_TEST(TestParse) {
+Y_UNIT_TEST_SUITE(TDurationParseTest) {
+ Y_UNIT_TEST(TestParse) {
UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(60 * 60 * 24 * 7), TDuration::Parse("1w"));
UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(60), TDuration::Parse("1m"));
UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(90), TDuration::Parse("1.5m"));
diff --git a/util/digest/city.cpp b/util/digest/city.cpp
index 7596cd96a0..c25f175d54 100644
--- a/util/digest/city.cpp
+++ b/util/digest/city.cpp
@@ -201,7 +201,7 @@ uint64 CityHash64WithSeed(const char* s, size_t len, uint64 seed) noexcept {
}
uint64 CityHash64WithSeeds(const char* s, size_t len,
- uint64 seed0, uint64 seed1) noexcept {
+ uint64 seed0, uint64 seed1) noexcept {
return HashLen16(CityHash64(s, len) - seed0, seed1);
}
@@ -310,7 +310,7 @@ uint128 CityHash128(const char* s, size_t len) noexcept {
}
}
-// TODO(yazevnul): move this function to unittests
+// TODO(yazevnul): move this function to unittests
void TestCompilationOfCityHashTemplates() {
TStringBuf s;
CityHash64(s);
diff --git a/util/digest/city.h b/util/digest/city.h
index 2d8cd8ead1..675a798074 100644
--- a/util/digest/city.h
+++ b/util/digest/city.h
@@ -5,16 +5,16 @@
#include <utility>
-// NOTE: These functions provide CityHash 1.0 implementation whose results are *different* from
-// the mainline version of CityHash.
-
+// NOTE: These functions provide CityHash 1.0 implementation whose results are *different* from
+// the mainline version of CityHash.
+
using uint128 = std::pair<ui64, ui64>;
-constexpr ui64 Uint128Low64(const uint128& x) {
+constexpr ui64 Uint128Low64(const uint128& x) {
return x.first;
}
-constexpr ui64 Uint128High64(const uint128& x) {
+constexpr ui64 Uint128High64(const uint128& x) {
return x.second;
}
@@ -33,7 +33,7 @@ Y_PURE_FUNCTION uint128 CityHash128WithSeed(const char* s, size_t len, uint128 s
// Hash 128 input bits down to 64 bits of output.
// This is intended to be a reasonably good hash function.
-inline ui64 Hash128to64(const uint128& x) {
+inline ui64 Hash128to64(const uint128& x) {
// Murmur-inspired hashing.
const ui64 kMul = 0x9ddfea08eb382d69ULL;
ui64 a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
@@ -44,40 +44,40 @@ inline ui64 Hash128to64(const uint128& x) {
return b;
}
-namespace NPrivateCityHash {
- template <class TStringType>
- inline TStringBuf GetBufFromStr(const TStringType& str) {
- static_assert(std::is_integral<std::remove_reference_t<decltype(*str.data())>>::value, "invalid type passed to hash function");
- return TStringBuf(reinterpret_cast<const char*>(str.data()), (str.size()) * sizeof(*str.data()));
- }
+namespace NPrivateCityHash {
+ template <class TStringType>
+ inline TStringBuf GetBufFromStr(const TStringType& str) {
+ static_assert(std::is_integral<std::remove_reference_t<decltype(*str.data())>>::value, "invalid type passed to hash function");
+ return TStringBuf(reinterpret_cast<const char*>(str.data()), (str.size()) * sizeof(*str.data()));
+ }
}
template <class TStringType>
inline ui64 CityHash64(const TStringType& str) {
- TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
- return CityHash64(buf.data(), buf.size());
+ TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
+ return CityHash64(buf.data(), buf.size());
}
template <class TStringType>
inline ui64 CityHash64WithSeeds(const TStringType& str, ui64 seed0, ui64 seed1) {
- TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
- return CityHash64WithSeeds(buf.data(), buf.size(), seed0, seed1);
+ TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
+ return CityHash64WithSeeds(buf.data(), buf.size(), seed0, seed1);
}
template <class TStringType>
inline ui64 CityHash64WithSeed(const TStringType& str, ui64 seed) {
- TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
- return CityHash64WithSeed(buf.data(), buf.size(), seed);
+ TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
+ return CityHash64WithSeed(buf.data(), buf.size(), seed);
}
template <class TStringType>
inline uint128 CityHash128(const TStringType& str) {
- TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
- return CityHash128(buf.data(), buf.size());
+ TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
+ return CityHash128(buf.data(), buf.size());
}
template <class TStringType>
inline uint128 CityHash128WithSeed(const TStringType& str, uint128 seed) {
- TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
- return CityHash128WithSeed(buf.data(), buf.size(), seed);
+ TStringBuf buf = NPrivateCityHash::GetBufFromStr(str);
+ return CityHash128WithSeed(buf.data(), buf.size(), seed);
}
diff --git a/util/digest/fnv.h b/util/digest/fnv.h
index 957ba9b9f1..87b41a3de7 100644
--- a/util/digest/fnv.h
+++ b/util/digest/fnv.h
@@ -9,7 +9,7 @@
namespace NFnvPrivate {
template <class It>
- constexpr ui32 FnvHash32(It b, It e, ui32 init) {
+ constexpr ui32 FnvHash32(It b, It e, ui32 init) {
while (b != e) {
init = (init * FNV32PRIME) ^ (unsigned char)*b++;
}
@@ -18,7 +18,7 @@ namespace NFnvPrivate {
}
template <class It>
- constexpr ui64 FnvHash64(It b, It e, ui64 init) {
+ constexpr ui64 FnvHash64(It b, It e, ui64 init) {
while (b != e) {
init = (init * FNV64PRIME) ^ (unsigned char)*b++;
}
@@ -34,7 +34,7 @@ namespace NFnvPrivate {
struct TFnvHelper<t> { \
static const ui##t Init = FNV##t##INIT; \
template <class It> \
- static constexpr ui##t FnvHash(It b, It e, ui##t init) { \
+ static constexpr ui##t FnvHash(It b, It e, ui##t init) { \
return FnvHash##t(b, e, init); \
} \
};
@@ -46,28 +46,28 @@ namespace NFnvPrivate {
}
template <class T, class It>
-static constexpr T FnvHash(It b, It e, T init) {
+static constexpr T FnvHash(It b, It e, T init) {
static_assert(sizeof(*b) == 1, "expect sizeof(*b) == 1");
return (T)NFnvPrivate::TFnvHelper<8 * sizeof(T)>::FnvHash(b, e, init);
}
template <class T, class It>
-static constexpr T FnvHash(It b, It e) {
+static constexpr T FnvHash(It b, It e) {
return FnvHash<T>(b, e, (T)NFnvPrivate::TFnvHelper<8 * sizeof(T)>::Init);
}
template <class T>
-static constexpr T FnvHash(const void* buf, size_t len, T init) {
+static constexpr T FnvHash(const void* buf, size_t len, T init) {
return FnvHash<T>((const unsigned char*)buf, (const unsigned char*)buf + len, init);
}
template <class T>
-static constexpr T FnvHash(const void* buf, size_t len) {
+static constexpr T FnvHash(const void* buf, size_t len) {
return FnvHash<T>((const unsigned char*)buf, (const unsigned char*)buf + len);
}
template <class T, class Buf>
-static constexpr T FnvHash(const Buf& buf) {
+static constexpr T FnvHash(const Buf& buf) {
return FnvHash<T>(buf.data(), buf.size() * sizeof(*buf.data()));
}
diff --git a/util/digest/multi.h b/util/digest/multi.h
index 92de71e783..8e4597c9dc 100644
--- a/util/digest/multi.h
+++ b/util/digest/multi.h
@@ -5,7 +5,7 @@
#include "numeric.h"
template <typename TOne>
-constexpr size_t MultiHash(const TOne& one) noexcept {
+constexpr size_t MultiHash(const TOne& one) noexcept {
return THash<TOne>()(one);
}
template <typename THead, typename... TTail>
diff --git a/util/digest/multi_ut.cpp b/util/digest/multi_ut.cpp
index 71c188c39a..dff64ff0cc 100644
--- a/util/digest/multi_ut.cpp
+++ b/util/digest/multi_ut.cpp
@@ -2,7 +2,7 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
class TMultiHashTest: public TTestBase {
UNIT_TEST_SUITE(TMultiHashTest);
diff --git a/util/digest/murmur.cpp b/util/digest/murmur.cpp
index 8fe21d3a04..b041d3e5f2 100644
--- a/util/digest/murmur.cpp
+++ b/util/digest/murmur.cpp
@@ -1,7 +1,7 @@
#include "murmur.h"
-#include <util/system/unaligned_mem.h>
-
+#include <util/system/unaligned_mem.h>
+
namespace NMurmurPrivate {
//-----------------------------------------------------------------------------
// MurmurHash2, by Austin Appleby
diff --git a/util/digest/murmur_ut.cpp b/util/digest/murmur_ut.cpp
index ecb10a9dac..29287668bc 100644
--- a/util/digest/murmur_ut.cpp
+++ b/util/digest/murmur_ut.cpp
@@ -76,7 +76,7 @@ private:
}
template <class E, class T>
- inline void TestWrapper(const TArrayRef<E>& array, T expected) {
+ inline void TestWrapper(const TArrayRef<E>& array, T expected) {
auto val = TMurmurHash<T>()(array);
UNIT_ASSERT_EQUAL(val, expected);
}
diff --git a/util/digest/numeric.h b/util/digest/numeric.h
index 59b60d1c2e..e20bd908e4 100644
--- a/util/digest/numeric.h
+++ b/util/digest/numeric.h
@@ -8,7 +8,7 @@
* copy: https://gist.github.com/badboy/6267743
*/
-static constexpr ui8 IntHashImpl(ui8 key8) noexcept {
+static constexpr ui8 IntHashImpl(ui8 key8) noexcept {
size_t key = key8;
key += ~(key << 15);
@@ -21,7 +21,7 @@ static constexpr ui8 IntHashImpl(ui8 key8) noexcept {
return static_cast<ui8>(key);
}
-static constexpr ui16 IntHashImpl(ui16 key16) noexcept {
+static constexpr ui16 IntHashImpl(ui16 key16) noexcept {
size_t key = key16;
key += ~(key << 15);
@@ -34,7 +34,7 @@ static constexpr ui16 IntHashImpl(ui16 key16) noexcept {
return static_cast<ui16>(key);
}
-static constexpr ui32 IntHashImpl(ui32 key) noexcept {
+static constexpr ui32 IntHashImpl(ui32 key) noexcept {
key += ~(key << 15);
key ^= (key >> 10);
key += (key << 3);
@@ -45,7 +45,7 @@ static constexpr ui32 IntHashImpl(ui32 key) noexcept {
return key;
}
-static constexpr ui64 IntHashImpl(ui64 key) noexcept {
+static constexpr ui64 IntHashImpl(ui64 key) noexcept {
key += ~(key << 32);
key ^= (key >> 22);
key += ~(key << 13);
@@ -59,8 +59,8 @@ static constexpr ui64 IntHashImpl(ui64 key) noexcept {
}
template <class T>
-static constexpr T IntHash(T t) noexcept {
- using TCvt = TFixedWidthUnsignedInt<T>;
+static constexpr T IntHash(T t) noexcept {
+ using TCvt = TFixedWidthUnsignedInt<T>;
return IntHashImpl((TCvt)(t));
}
@@ -69,8 +69,8 @@ static constexpr T IntHash(T t) noexcept {
* can handle floats && pointers
*/
template <class T>
-static constexpr size_t NumericHash(T t) noexcept {
- using TCvt = TFixedWidthUnsignedInt<T>;
+static constexpr size_t NumericHash(T t) noexcept {
+ using TCvt = TFixedWidthUnsignedInt<T>;
union Y_HIDDEN {
T t;
@@ -81,6 +81,6 @@ static constexpr size_t NumericHash(T t) noexcept {
}
template <class T>
-static constexpr T CombineHashes(T l, T r) noexcept {
+static constexpr T CombineHashes(T l, T r) noexcept {
return IntHash(l) ^ r;
}
diff --git a/util/digest/sequence.h b/util/digest/sequence.h
index 3329ac70c3..712331007b 100644
--- a/util/digest/sequence.h
+++ b/util/digest/sequence.h
@@ -42,7 +42,7 @@ public:
}
template <typename ElementType>
- auto operator()(const TArrayRef<ElementType>& data) const {
+ auto operator()(const TArrayRef<ElementType>& data) const {
return TBase<ElementType>()(data);
}
};
diff --git a/util/digest/sequence_ut.cpp b/util/digest/sequence_ut.cpp
index 369339f730..87d6102ee5 100644
--- a/util/digest/sequence_ut.cpp
+++ b/util/digest/sequence_ut.cpp
@@ -54,7 +54,7 @@ private:
int arr[] = {1, 2, 3};
const size_t canonicalHash = static_cast<size_t>(ULL(3903918011533391876));
TContiguousHash<TSimpleRangeHash> hasher;
- UNIT_ASSERT_EQUAL(canonicalHash, hasher(TArrayRef<int>(arr, arr + 3)));
+ UNIT_ASSERT_EQUAL(canonicalHash, hasher(TArrayRef<int>(arr, arr + 3)));
}
};
diff --git a/util/draft/date.h b/util/draft/date.h
index 13d86032b7..e3eb616fe5 100644
--- a/util/draft/date.h
+++ b/util/draft/date.h
@@ -1,7 +1,7 @@
#pragma once
-#include <util/stream/output.h>
-#include <util/stream/input.h>
+#include <util/stream/output.h>
+#include <util/stream/input.h>
#include <util/generic/string.h>
#include <util/datetime/constants.h>
@@ -83,8 +83,8 @@ public:
friend bool operator==(const TDate& left, const TDate& right);
friend int operator-(const TDate& left, const TDate& right);
- friend IInputStream& operator>>(IInputStream& left, TDate& right);
- friend IOutputStream& operator<<(IOutputStream& left, const TDate& right);
+ friend IInputStream& operator>>(IInputStream& left, TDate& right);
+ friend IOutputStream& operator<<(IOutputStream& left, const TDate& right);
};
Y_DECLARE_PODTYPE(TDate);
@@ -116,7 +116,7 @@ inline int operator-(const TDate& left, const TDate& right) {
return static_cast<int>((left.Timestamp + SECONDS_IN_DAY / 2 - right.Timestamp) / SECONDS_IN_DAY);
}
-inline IInputStream& operator>>(IInputStream& left, TDate& right) {
+inline IInputStream& operator>>(IInputStream& left, TDate& right) {
TString stroka;
left >> stroka;
TDate date(stroka.c_str());
@@ -124,6 +124,6 @@ inline IInputStream& operator>>(IInputStream& left, TDate& right) {
return left;
}
-inline IOutputStream& operator<<(IOutputStream& left, const TDate& right) {
+inline IOutputStream& operator<<(IOutputStream& left, const TDate& right) {
return left << right.ToStroka();
}
diff --git a/util/draft/date_ut.cpp b/util/draft/date_ut.cpp
index 0efb5c5a36..8c33a6c1cf 100644
--- a/util/draft/date_ut.cpp
+++ b/util/draft/date_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TDateTest) {
- Y_UNIT_TEST(ComponentsTest) {
+Y_UNIT_TEST_SUITE(TDateTest) {
+ Y_UNIT_TEST(ComponentsTest) {
{
TDate d("20110215");
UNIT_ASSERT_EQUAL(d.GetYear(), 2011);
diff --git a/util/draft/datetime.cpp b/util/draft/datetime.cpp
index 902431734d..5cbe7d8847 100644
--- a/util/draft/datetime.cpp
+++ b/util/draft/datetime.cpp
@@ -6,7 +6,7 @@
#include <util/system/fasttime.h>
#include <util/datetime/base.h>
#include <util/datetime/systime.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/stream/mem.h>
#include <util/string/cast.h>
#include <util/string/printf.h>
@@ -28,12 +28,12 @@ namespace NDatetime {
// [31, ..., 365] or [31, ..., 366] (12 elements)
const ui32* pos = UpperBound(begin, end, yday);
- Y_ENSURE(pos != end, "day no. " << yday << " does not exist in " << (isleap ? "leap" : "non-leap") << " year");
+ Y_ENSURE(pos != end, "day no. " << yday << " does not exist in " << (isleap ? "leap" : "non-leap") << " year");
*month = pos - begin;
*mday = yday - *(pos - 1) + 1;
- Y_ASSERT((*month < 12) && (1 <= *mday) && (*mday <= MonthDays[isleap][*month]));
+ Y_ASSERT((*month < 12) && (1 <= *mday) && (*mday <= MonthDays[isleap][*month]));
}
struct TTimeData {
@@ -215,7 +215,7 @@ namespace NDatetime {
}
template <>
-void In<TMonth>(IInputStream& in, TMonth& t) {
+void In<TMonth>(IInputStream& in, TMonth& t) {
char buf[4];
LoadPodArray(&in, buf, 4);
t.Year = FromString<ui16>(buf, 4);
@@ -224,7 +224,7 @@ void In<TMonth>(IInputStream& in, TMonth& t) {
}
template <>
-void Out<TMonth>(IOutputStream& o, const TMonth& t) {
+void Out<TMonth>(IOutputStream& o, const TMonth& t) {
o << t.Year << Sprintf("%.2hu", (ui16)(t.Month + 1));
}
diff --git a/util/draft/datetime_ut.cpp b/util/draft/datetime_ut.cpp
index b64fdaa36a..a5e065ef6e 100644
--- a/util/draft/datetime_ut.cpp
+++ b/util/draft/datetime_ut.cpp
@@ -4,7 +4,7 @@
#include <util/string/builder.h>
-Y_UNIT_TEST_SUITE(TSimpleTMTest) {
+Y_UNIT_TEST_SUITE(TSimpleTMTest) {
TString PrintMarker(const TString& test, int line) {
return TStringBuilder() << "test " << test << " at line " << line;
}
@@ -52,7 +52,7 @@ Y_UNIT_TEST_SUITE(TSimpleTMTest) {
UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Sec, sec, marker);
}
- Y_UNIT_TEST(TestLeap) {
+ Y_UNIT_TEST(TestLeap) {
using namespace NDatetime;
UNIT_ASSERT(LeapYearAD(2000));
UNIT_ASSERT(LeapYearAD(2012));
@@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(TSimpleTMTest) {
UNIT_ASSERT(!LeapYearAD(1900));
}
- Y_UNIT_TEST(TestYDayConversion) {
+ Y_UNIT_TEST(TestYDayConversion) {
using namespace NDatetime;
ui32 month;
ui32 mday;
@@ -79,7 +79,7 @@ Y_UNIT_TEST_SUITE(TSimpleTMTest) {
UNIT_ASSERT_EXCEPTION(YDayToMonthAndDay(366, true, &month, &mday), yexception);
}
- Y_UNIT_TEST(SimpleTMTest) {
+ Y_UNIT_TEST(SimpleTMTest) {
using namespace NDatetime;
tzset();
diff --git a/util/draft/enum.h b/util/draft/enum.h
index cdee12564b..18002b7df2 100644
--- a/util/draft/enum.h
+++ b/util/draft/enum.h
@@ -11,13 +11,13 @@
class TEnumNotFoundException: public yexception {
};
-#define EnumFromString(key, entries) EnumFromStringImpl(key, entries, Y_ARRAY_SIZE(entries))
+#define EnumFromString(key, entries) EnumFromStringImpl(key, entries, Y_ARRAY_SIZE(entries))
#define EnumFromStringWithSize(key, entries, size) EnumFromStringImpl(key, entries, size)
-#define FindEnumFromString(key, entries) FindEnumFromStringImpl(key, entries, Y_ARRAY_SIZE(entries))
+#define FindEnumFromString(key, entries) FindEnumFromStringImpl(key, entries, Y_ARRAY_SIZE(entries))
#define FindEnumFromStringWithSize(key, entries, size) FindEnumFromStringImpl(key, entries, size)
-#define EnumToString(key, entries) EnumToStringImpl(key, entries, Y_ARRAY_SIZE(entries))
+#define EnumToString(key, entries) EnumToStringImpl(key, entries, Y_ARRAY_SIZE(entries))
#define EnumToStringWithSize(key, entries, size) EnumToStringImpl(key, entries, size)
-#define PrintEnumItems(entries) PrintEnumItemsImpl(entries, Y_ARRAY_SIZE(entries))
+#define PrintEnumItems(entries) PrintEnumItemsImpl(entries, Y_ARRAY_SIZE(entries))
template <class K1, class K2, class V>
const V* FindEnumFromStringImpl(K1 key, const std::pair<K2, V>* entries, size_t arraySize) {
diff --git a/util/draft/holder_vector.h b/util/draft/holder_vector.h
index 022f83cff2..1c62055bd9 100644
--- a/util/draft/holder_vector.h
+++ b/util/draft/holder_vector.h
@@ -52,7 +52,7 @@ public:
void Reset(size_t i, THolder<T> t) {
T* current = (*this)[i];
if (current) {
- Y_ASSERT(current != t.Get());
+ Y_ASSERT(current != t.Get());
D::Destroy(current);
}
(*this)[i] = t.Release();
diff --git a/util/draft/holder_vector_ut.cpp b/util/draft/holder_vector_ut.cpp
index babcfe8ea0..f64393860a 100644
--- a/util/draft/holder_vector_ut.cpp
+++ b/util/draft/holder_vector_ut.cpp
@@ -2,14 +2,14 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(THolderVectorTest) {
- Y_UNIT_TEST(TestCreateEmpty) {
+Y_UNIT_TEST_SUITE(THolderVectorTest) {
+ Y_UNIT_TEST(TestCreateEmpty) {
THolderVector<int> ints;
UNIT_ASSERT_EQUAL(ints.Size(), 0);
UNIT_ASSERT(!ints);
}
- Y_UNIT_TEST(TestCreateNonEmpty) {
+ Y_UNIT_TEST(TestCreateNonEmpty) {
THolderVector<int> ints(5);
UNIT_ASSERT_EQUAL(ints.Size(), 5);
UNIT_ASSERT(ints);
@@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) {
}
}
- Y_UNIT_TEST(TestResetValue) {
+ Y_UNIT_TEST(TestResetValue) {
THolderVector<int> ints;
ints.PushBack(new int(0));
ints.PushBack(new int(1));
@@ -31,7 +31,7 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) {
UNIT_ASSERT_VALUES_EQUAL(*ints[1], 3);
}
- Y_UNIT_TEST(TestResetNoValue) {
+ Y_UNIT_TEST(TestResetNoValue) {
THolderVector<int> ints;
ints.Resize(1);
UNIT_ASSERT_EQUAL(ints[0], (int*)nullptr);
@@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) {
UNIT_ASSERT_VALUES_EQUAL(*ints[0], 1);
}
- Y_UNIT_TEST(TestResetSmartPtr) {
+ Y_UNIT_TEST(TestResetSmartPtr) {
THolderVector<int> ints;
ints.Resize(2);
@@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) {
UNIT_ASSERT(!holder);
}
- Y_UNIT_TEST(TestSwap) {
+ Y_UNIT_TEST(TestSwap) {
THolderVector<int> v1;
v1.PushBack(new int(1));
@@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) {
UNIT_ASSERT(v1.empty() && v2.size() == 1 && *v2.front() == 1);
}
- Y_UNIT_TEST(TestUniquePtr) {
+ Y_UNIT_TEST(TestUniquePtr) {
THolderVector<TString> v;
std::unique_ptr<TString> str(new TString("hello"));
v.PushBack(std::move(str));
diff --git a/util/draft/ip.h b/util/draft/ip.h
index 97ddba39d5..eb947cd2cd 100644
--- a/util/draft/ip.h
+++ b/util/draft/ip.h
@@ -87,7 +87,7 @@ static inline TString Ip6ToString(const TIp6& ip) {
}
template <>
-inline void Out<TIp6>(IOutputStream& os, const TIp6& a) {
+inline void Out<TIp6>(IOutputStream& os, const TIp6& a) {
os << Ip6ToString(a);
}
diff --git a/util/draft/matrix.h b/util/draft/matrix.h
index 5b366d32b9..154d00b35e 100644
--- a/util/draft/matrix.h
+++ b/util/draft/matrix.h
@@ -47,7 +47,7 @@ public:
}
void ReDim(size_t m, size_t n) {
- Y_ASSERT(m >= 1 && n >= 1);
+ Y_ASSERT(m >= 1 && n >= 1);
size_t newSize = m * n;
if (newSize > BufSize) {
T* newBuf = new T[newSize];
@@ -69,25 +69,25 @@ public:
// Access element matrix[i][j]
T* operator[](size_t i) {
- Y_ASSERT(i >= 0 && i < M);
+ Y_ASSERT(i >= 0 && i < M);
return Arr + i * N;
}
// Access element matrix[i][j]
const T* operator[](size_t i) const {
- Y_ASSERT(i >= 0 && i < M);
+ Y_ASSERT(i >= 0 && i < M);
return Arr + i * N;
}
// Access element matrix(i, j)
T& operator()(size_t i, size_t j) {
- Y_ASSERT(i >= 0 && i < M && j >= 0 && j < N);
+ Y_ASSERT(i >= 0 && i < M && j >= 0 && j < N);
return Arr[i * N + j];
}
// Access element matrix(i, j)
const T& operator()(size_t i, size_t j) const {
- Y_ASSERT(i >= 0 && i < M && j >= 0 && j < N);
+ Y_ASSERT(i >= 0 && i < M && j >= 0 && j < N);
return Arr[i * N + j];
}
diff --git a/util/draft/memory_ut.cpp b/util/draft/memory_ut.cpp
index ef416705d5..76bee30549 100644
--- a/util/draft/memory_ut.cpp
+++ b/util/draft/memory_ut.cpp
@@ -23,8 +23,8 @@ struct Y_PACKED TSampleStruct3 {
#pragma pack()
-Y_UNIT_TEST_SUITE(TUtilDraftMemoryTest) {
- Y_UNIT_TEST(IsZeroTest) {
+Y_UNIT_TEST_SUITE(TUtilDraftMemoryTest) {
+ Y_UNIT_TEST(IsZeroTest) {
ui8 a1 = 0;
UNIT_ASSERT(IsZero(a1));
a1 = 0xF0;
diff --git a/util/folder/dirent_win.c b/util/folder/dirent_win.c
index 3eef8c9762..7e6db74ce5 100644
--- a/util/folder/dirent_win.c
+++ b/util/folder/dirent_win.c
@@ -39,7 +39,7 @@ struct DIR* opendir(const char* dirname) {
closedir(dir);
return NULL;
}
- dir->fff_templ = (WCHAR*)malloc((len_converted + 5) * sizeof(WCHAR));
+ dir->fff_templ = (WCHAR*)malloc((len_converted + 5) * sizeof(WCHAR));
if (!dir->fff_templ) {
closedir(dir);
return NULL;
diff --git a/util/folder/dirut.cpp b/util/folder/dirut.cpp
index ebb1854c28..ffc9b09f96 100644
--- a/util/folder/dirut.cpp
+++ b/util/folder/dirut.cpp
@@ -5,8 +5,8 @@
#include "pathsplit.h"
#include "path.h"
-#include <util/generic/yexception.h>
-#include <util/system/compiler.h>
+#include <util/generic/yexception.h>
+#include <util/system/compiler.h>
#include <util/system/fs.h>
#include <util/system/maxlen.h>
#include <util/system/yassert.h>
@@ -30,13 +30,13 @@ bool correctpath(TString& folder) {
}
bool resolvepath(TString& folder, const TString& home) {
- Y_ASSERT(home && home.at(0) == '/');
+ Y_ASSERT(home && home.at(0) == '/');
if (!folder) {
return false;
}
// may be from windows
char* ptr = folder.begin();
- while ((ptr = strchr(ptr, '\\')) != nullptr)
+ while ((ptr = strchr(ptr, '\\')) != nullptr)
*ptr = '/';
if (folder.at(0) == '~') {
@@ -383,14 +383,14 @@ void RemoveDirWithContents(TString dirName) {
for (auto it = dir.begin(); it != dir.end(); ++it) {
switch (it->fts_info) {
- case FTS_F:
- case FTS_DEFAULT:
- case FTS_DP:
- case FTS_SL:
- case FTS_SLNONE:
- if (!NFs::Remove(it->fts_path))
- ythrow TSystemError() << "error while removing " << it->fts_path;
- break;
+ case FTS_F:
+ case FTS_DEFAULT:
+ case FTS_DP:
+ case FTS_SL:
+ case FTS_SLNONE:
+ if (!NFs::Remove(it->fts_path))
+ ythrow TSystemError() << "error while removing " << it->fts_path;
+ break;
}
}
}
@@ -404,7 +404,7 @@ int mkpath(char* path, int mode) {
// if it does not). Use RealLocation if that behaviour is required.
TString RealPath(const TString& path) {
TTempBuf result;
- Y_ASSERT(result.Size() > MAX_PATH); //TMP_BUF_LEN > MAX_PATH
+ Y_ASSERT(result.Size() > MAX_PATH); //TMP_BUF_LEN > MAX_PATH
#ifdef _win_
if (GetFullPathName(path.data(), result.Size(), result.Data(), nullptr) == 0)
#else
@@ -437,7 +437,7 @@ int MakeTempDir(char path[/*FILENAME_MAX*/], const char* prefix) {
prefix = sysTmp.data();
}
- if ((ret = ResolvePath(prefix, nullptr, path, 1)) != 0)
+ if ((ret = ResolvePath(prefix, nullptr, path, 1)) != 0)
return ret;
if (!TFileStat(path).IsDir())
return ENOENT;
@@ -457,7 +457,7 @@ TString GetHomeDir() {
TString s(getenv("HOME"));
if (!s) {
#ifndef _win32_
- passwd* pw = nullptr;
+ passwd* pw = nullptr;
s = getenv("USER");
if (s)
pw = getpwnam(s.data());
@@ -468,7 +468,7 @@ TString GetHomeDir() {
else
#endif
{
- char* cur_dir = getcwd(nullptr, 0);
+ char* cur_dir = getcwd(nullptr, 0);
s = cur_dir;
free(cur_dir);
}
@@ -477,8 +477,8 @@ TString GetHomeDir() {
}
void MakeDirIfNotExist(const char* path, int mode) {
- if (!NFs::MakeDirectory(path, NFs::EFilePermission(mode)) && !NFs::Exists(path)) {
- ythrow TSystemError() << "failed to create directory " << path;
+ if (!NFs::MakeDirectory(path, NFs::EFilePermission(mode)) && !NFs::Exists(path)) {
+ ythrow TSystemError() << "failed to create directory " << path;
}
}
diff --git a/util/folder/dirut.h b/util/folder/dirut.h
index c2b870ae0c..2537027b12 100644
--- a/util/folder/dirut.h
+++ b/util/folder/dirut.h
@@ -106,11 +106,11 @@ public:
const char* Check(const char* fname) const {
if (!fname || !*fname)
- return nullptr;
+ return nullptr;
if (Strict) {
NFs::EnsureExists(fname);
} else if (!NFs::Exists(fname))
- fname = nullptr;
+ fname = nullptr;
return fname;
}
diff --git a/util/folder/filelist.cpp b/util/folder/filelist.cpp
index 87f2c69b2d..b21fcdbf20 100644
--- a/util/folder/filelist.cpp
+++ b/util/folder/filelist.cpp
@@ -26,7 +26,7 @@ void TFileEntitiesList::Fill(const TString& dirname, TStringBuf prefix, TStringB
TStringBuf filename = file->fts_path + dirNameLength + 1;
- if (filename.empty() || !filename.StartsWith(prefix) || !filename.EndsWith(suffix)) {
+ if (filename.empty() || !filename.StartsWith(prefix) || !filename.EndsWith(suffix)) {
continue;
}
diff --git a/util/folder/filelist.h b/util/folder/filelist.h
index a0f6e86ead..3f615fa4c2 100644
--- a/util/folder/filelist.h
+++ b/util/folder/filelist.h
@@ -26,14 +26,14 @@ public:
}
void Clear() {
- Cur = nullptr;
+ Cur = nullptr;
FileNamesSize = CurName = 0;
FileNames.Clear();
FileNames.Append("", 1);
}
const char* Next() {
- return Cur = (CurName++ < FileNamesSize ? strchr(Cur, 0) + 1 : nullptr);
+ return Cur = (CurName++ < FileNamesSize ? strchr(Cur, 0) + 1 : nullptr);
}
size_t Size() {
diff --git a/util/folder/filelist_ut.cpp b/util/folder/filelist_ut.cpp
index ec023f5094..0cdcdf3d00 100644
--- a/util/folder/filelist_ut.cpp
+++ b/util/folder/filelist_ut.cpp
@@ -27,7 +27,7 @@ void TFileListTest::TestSimple() {
fileList.Fill(tempDir().data(), "", "", 1000);
TString fileName(fileList.Next());
UNIT_ASSERT_EQUAL(fileName, "subdir" LOCSLASH_S "file");
- UNIT_ASSERT_EQUAL(fileList.Next(), nullptr);
+ UNIT_ASSERT_EQUAL(fileList.Next(), nullptr);
}
void TFileListTest::TestPrefix() {
diff --git a/util/folder/fts.cpp b/util/folder/fts.cpp
index 4ab22a94bf..0e6a6f86eb 100644
--- a/util/folder/fts.cpp
+++ b/util/folder/fts.cpp
@@ -33,9 +33,9 @@
* $OpenBSD: fts.c,v 1.22 1999/10/03 19:22:22 millert Exp $
*/
-#include <util/memory/tempbuf.h>
-#include <util/system/compat.h>
-#include <util/system/compiler.h>
+#include <util/memory/tempbuf.h>
+#include <util/system/compat.h>
+#include <util/system/compiler.h>
#include <util/system/defaults.h>
#include <util/system/error.h>
@@ -110,14 +110,14 @@ int stat64UTF(dird path, struct _stat64* _Stat) {
return _wstat64(path, _Stat);
}
-const dird invalidDirD = nullptr;
+const dird invalidDirD = nullptr;
dird get_cwdd() {
return _wgetcwd(nullptr, 0);
}
int valid_dird(dird fd) {
- return fd == nullptr;
+ return fd == nullptr;
}
void close_dird(dird fd) {
@@ -258,19 +258,19 @@ FTS* yfts_open(char* const* argv, int options, int (*compar)(const FTSENT**, con
/* Options check. */
if (options & ~FTS_OPTIONMASK) {
errno = EINVAL;
- return nullptr;
+ return nullptr;
}
/* Allocate/initialize the stream */
if ((sp = (FTS*)malloc(sizeof(FTS))) == nullptr) {
- return nullptr;
+ return nullptr;
}
memset(sp, 0, sizeof(FTS));
sp->fts_compar = compar;
sp->fts_options = options;
/* Shush, GCC. */
- tmp = nullptr;
+ tmp = nullptr;
/* Logical walks turn on NOCHDIR; symbolic links are too hard. */
if (ISSET(FTS_LOGICAL)) {
@@ -292,7 +292,7 @@ FTS* yfts_open(char* const* argv, int options, int (*compar)(const FTSENT**, con
parent->fts_level = FTS_ROOTPARENTLEVEL;
/* Allocate/initialize root(s). */
- for (root = nullptr, nitems = 0; *argv; ++argv, ++nitems) {
+ for (root = nullptr, nitems = 0; *argv; ++argv, ++nitems) {
/* Don't allow zero-length paths. */
len = strlen(*argv);
@@ -329,7 +329,7 @@ FTS* yfts_open(char* const* argv, int options, int (*compar)(const FTSENT**, con
p->fts_link = root;
root = p;
} else {
- p->fts_link = nullptr;
+ p->fts_link = nullptr;
if (root == nullptr) {
tmp = root = p;
} else {
@@ -375,7 +375,7 @@ mem2:
free(sp->fts_path);
mem1:
free(sp);
- return nullptr;
+ return nullptr;
}
static void
@@ -393,7 +393,7 @@ fts_load(FTS* sp, FTSENT* p)
*/
len = p->fts_pathlen = p->fts_namelen;
memmove((void*)sp->fts_path, (void*)p->fts_name, len + 1);
- if ((cp = strrchr(p->fts_name, LOCSLASH_C)) != nullptr && (cp != p->fts_name || cp[1])) {
+ if ((cp = strrchr(p->fts_name, LOCSLASH_C)) != nullptr && (cp != p->fts_name || cp[1])) {
len = strlen(++cp);
memmove((void*)p->fts_name, (void*)cp, len + 1);
p->fts_namelen = (u_short)len;
@@ -469,7 +469,7 @@ yfts_read(FTS* sp) {
/* If finished or unrecoverable error, return NULL. */
if (sp->fts_cur == nullptr || ISSET(FTS_STOP)) {
- return nullptr;
+ return nullptr;
}
/* Set current node pointer. */
@@ -517,7 +517,7 @@ yfts_read(FTS* sp) {
}
if (sp->fts_child) {
fts_lfree(sp->fts_child);
- sp->fts_child = nullptr;
+ sp->fts_child = nullptr;
}
p->fts_info = FTS_DP;
return (p);
@@ -527,7 +527,7 @@ yfts_read(FTS* sp) {
if (sp->fts_child && ISSET(FTS_NAMEONLY)) {
CLR(FTS_NAMEONLY);
fts_lfree(sp->fts_child);
- sp->fts_child = nullptr;
+ sp->fts_child = nullptr;
}
/*
@@ -551,21 +551,21 @@ yfts_read(FTS* sp) {
p->fts_parent->fts_accpath;
}
}
- } else if ((sp->fts_child = fts_build(sp, BREAD)) == nullptr) {
+ } else if ((sp->fts_child = fts_build(sp, BREAD)) == nullptr) {
if (ISSET(FTS_STOP)) {
- return nullptr;
+ return nullptr;
}
return (p);
}
p = sp->fts_child;
- sp->fts_child = nullptr;
+ sp->fts_child = nullptr;
goto name;
}
/* Move to the next node on this level. */
next:
tmp = p;
- if ((p = p->fts_link) != nullptr) {
+ if ((p = p->fts_link) != nullptr) {
free(tmp);
/*
@@ -575,7 +575,7 @@ next:
if (p->fts_level == FTS_ROOTLEVEL) {
if (FCHDIR(sp, sp->fts_rfd)) {
SET(FTS_STOP);
- return nullptr;
+ return nullptr;
}
fts_load(sp, p);
return (sp->fts_cur = p);
@@ -622,7 +622,7 @@ next:
*/
free(p);
errno = 0;
- return (sp->fts_cur = nullptr);
+ return (sp->fts_cur = nullptr);
}
/* NUL terminate the pathname. */
@@ -636,7 +636,7 @@ next:
if (p->fts_level == FTS_ROOTLEVEL) {
if (FCHDIR(sp, sp->fts_rfd)) {
SET(FTS_STOP);
- return nullptr;
+ return nullptr;
}
} else if (p->fts_flags & FTS_SYMFOLLOW) {
if (FCHDIR(sp, p->fts_symfd)) {
@@ -644,7 +644,7 @@ next:
close_dird(p->fts_symfd);
errno = saved_errno;
SET(FTS_STOP);
- return nullptr;
+ return nullptr;
}
close_dird(p->fts_symfd);
} else if (!(p->fts_flags & FTS_DONTCHDIR) &&
@@ -682,7 +682,7 @@ yfts_children(FTS* sp, int instr)
dird fd;
if (instr && instr != FTS_NAMEONLY) {
errno = EINVAL;
- return nullptr;
+ return nullptr;
}
/* Set current node pointer. */
@@ -696,7 +696,7 @@ yfts_children(FTS* sp, int instr)
/* Fatal errors stop here. */
if (ISSET(FTS_STOP)) {
- return nullptr;
+ return nullptr;
}
/* Return logical hierarchy of user's arguments. */
@@ -710,7 +710,7 @@ yfts_children(FTS* sp, int instr)
* same effect is available with FTS_AGAIN.
*/
if (p->fts_info != FTS_D /* && p->fts_info != FTS_DNR */) {
- return nullptr;
+ return nullptr;
}
/* Free up any previous child list. */
@@ -738,28 +738,28 @@ yfts_children(FTS* sp, int instr)
}
if (valid_dird(fd = get_cwdd())) {
- return nullptr;
+ return nullptr;
}
sp->fts_child = fts_build(sp, instr);
if (chdir_dird(fd)) {
close_dird(fd);
- return nullptr;
+ return nullptr;
}
close_dird(fd);
return (sp->fts_child);
}
static inline struct dirent* yreaddir(DIR* dir, struct dirent* de) {
- // TODO(yazevnul|IGNIETFERRO-1070): remove these macroses by replacing `readdir_r` with proper
- // alternative
- Y_PRAGMA_DIAGNOSTIC_PUSH
- Y_PRAGMA_NO_DEPRECATED
+ // TODO(yazevnul|IGNIETFERRO-1070): remove these macroses by replacing `readdir_r` with proper
+ // alternative
+ Y_PRAGMA_DIAGNOSTIC_PUSH
+ Y_PRAGMA_NO_DEPRECATED
if (readdir_r(dir, de, &de) == 0) {
Y_PRAGMA_DIAGNOSTIC_POP
return de;
}
- return nullptr;
+ return nullptr;
}
/*
@@ -811,12 +811,12 @@ fts_build(FTS* sp, int type)
#else
#define __opendir2(path, flag) opendir(path)
#endif
- if ((dirp = __opendir2(cur->fts_accpath, oflag)) == nullptr) {
+ if ((dirp = __opendir2(cur->fts_accpath, oflag)) == nullptr) {
if (type == BREAD) {
cur->fts_info = FTS_DNR;
cur->fts_errno = errno;
}
- return nullptr;
+ return nullptr;
}
#ifdef _win_
@@ -858,7 +858,7 @@ fts_build(FTS* sp, int type)
cderrno = 0;
if (nlinks || type == BREAD) {
#ifndef _win_
- if (fts_safe_changedir(sp, cur, dirfd(dirp), nullptr)) {
+ if (fts_safe_changedir(sp, cur, dirfd(dirp), nullptr)) {
#else
if (fts_safe_changedir(sp, cur, -1, dirpd)) {
#endif
@@ -870,12 +870,12 @@ fts_build(FTS* sp, int type)
descend = 0;
cderrno = errno;
(void)closedir(dirp);
- dirp = nullptr;
+ dirp = nullptr;
#ifdef _win_
close_dird(dirpd);
dirpd = invalidDirD;
#else
- Y_UNUSED(invalidDirD);
+ Y_UNUSED(invalidDirD);
#endif
} else {
descend = 1;
@@ -900,7 +900,7 @@ fts_build(FTS* sp, int type)
*cp++ = LOCSLASH_C;
} else {
/* GCC, you're too verbose. */
- cp = nullptr;
+ cp = nullptr;
}
++len;
maxlen = sp->fts_pathlen - len;
@@ -913,7 +913,7 @@ fts_build(FTS* sp, int type)
//to ensure enough buffer
TTempBuf dpe;
- for (head = tail = nullptr, nitems = 0; dirp && (dp = yreaddir(dirp, (struct dirent*)dpe.Data())) != nullptr;) {
+ for (head = tail = nullptr, nitems = 0; dirp && (dp = yreaddir(dirp, (struct dirent*)dpe.Data())) != nullptr;) {
if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) {
continue;
}
@@ -942,7 +942,7 @@ fts_build(FTS* sp, int type)
cur->fts_info = FTS_ERR;
SET(FTS_STOP);
errno = saved_errno;
- return nullptr;
+ return nullptr;
}
/* Did realloc() change the pointer? */
if (oldaddr != sp->fts_path) {
@@ -970,7 +970,7 @@ fts_build(FTS* sp, int type)
cur->fts_info = FTS_ERR;
SET(FTS_STOP);
errno = ENAMETOOLONG;
- return nullptr;
+ return nullptr;
}
p->fts_level = (short)level;
p->fts_parent = sp->fts_cur;
@@ -1029,7 +1029,7 @@ fts_build(FTS* sp, int type)
}
/* We walk in directory order so "ls -f" doesn't get upset. */
- p->fts_link = nullptr;
+ p->fts_link = nullptr;
if (head == nullptr) {
head = tail = p;
} else {
@@ -1076,7 +1076,7 @@ fts_build(FTS* sp, int type)
cur->fts_info = FTS_ERR;
SET(FTS_STOP);
fts_lfree(head);
- return nullptr;
+ return nullptr;
}
/* If didn't find anything, return NULL. */
@@ -1085,7 +1085,7 @@ fts_build(FTS* sp, int type)
cur->fts_info = FTS_DP;
}
fts_lfree(head);
- return nullptr;
+ return nullptr;
}
/* Sort the entries. */
@@ -1206,7 +1206,7 @@ fts_sort(FTS* sp, FTSENT* head, int nitems)
if (sp->fts_array) {
free(sp->fts_array);
}
- sp->fts_array = nullptr;
+ sp->fts_array = nullptr;
sp->fts_nitems = 0;
return (head);
}
@@ -1219,7 +1219,7 @@ fts_sort(FTS* sp, FTSENT* head, int nitems)
for (head = *(ap = sp->fts_array); --nitems; ++ap) {
ap[0]->fts_link = ap[1];
}
- ap[0]->fts_link = nullptr;
+ ap[0]->fts_link = nullptr;
return (head);
}
@@ -1242,7 +1242,7 @@ fts_alloc(FTS* sp, const char* name, int namelen)
len += sizeof(stat_struct) + ALIGNBYTES;
}
if ((p = (FTSENT*)malloc(len)) == nullptr) {
- return nullptr;
+ return nullptr;
}
/* Copy the name and guarantee NUL termination. */
@@ -1258,7 +1258,7 @@ fts_alloc(FTS* sp, const char* name, int namelen)
p->fts_flags = 0;
p->fts_instr = FTS_NOINSTR;
p->fts_number = 0;
- p->fts_pointer = nullptr;
+ p->fts_pointer = nullptr;
p->fts_type = FTS_NSOK;
return (p);
}
@@ -1269,7 +1269,7 @@ fts_lfree(FTSENT* head)
FTSENT* p;
/* Free a linked list of structures. */
- while ((p = head) != nullptr) {
+ while ((p = head) != nullptr) {
head = head->fts_link;
free(p);
}
@@ -1286,7 +1286,7 @@ fts_palloc(FTS* sp, size_t more)
{
sp->fts_pathlen += more + 256;
sp->fts_path = (char*)yreallocf(sp->fts_path, (size_t)sp->fts_pathlen);
- return (sp->fts_path == nullptr);
+ return (sp->fts_path == nullptr);
}
static void
diff --git a/util/folder/fts.h b/util/folder/fts.h
index 8b25d9eacd..f3c799e8c8 100644
--- a/util/folder/fts.h
+++ b/util/folder/fts.h
@@ -17,7 +17,7 @@ typedef struct _stat64 stat_struct;
#define STAT_FUNC stat64UTF
//TODO: remove from global scope stat64UTF stat64UTF
#ifdef __cplusplus
-int stat64UTF(const char* path, struct _stat64* _Stat);
+int stat64UTF(const char* path, struct _stat64* _Stat);
int stat64UTF(dird path, struct _stat64* _Stat);
#endif
#endif
diff --git a/util/folder/fts_ut.cpp b/util/folder/fts_ut.cpp
index 7fffa5ecb0..c5d59e35f4 100644
--- a/util/folder/fts_ut.cpp
+++ b/util/folder/fts_ut.cpp
@@ -54,7 +54,7 @@ private:
};
void TFtsTest::TestSimple() {
- const char* dotPath[2] = {"." LOCSLASH_S, nullptr};
+ const char* dotPath[2] = {"." LOCSLASH_S, nullptr};
TFileTree currentDirTree((char* const*)dotPath, 0, FtsCmp);
UNIT_ASSERT(currentDirTree());
TTempDir tempDir = MakeTempName(yfts_read(currentDirTree())->fts_path);
@@ -79,7 +79,7 @@ void TFtsTest::TestSimple() {
CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2" LOCSLASH_S "file4").data(), FTS_F);
CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2").data(), FTS_DP);
CheckEnt(yfts_read(fileTree()), (tempDir()).data(), FTS_DP);
- UNIT_ASSERT_EQUAL(yfts_read(fileTree()), nullptr);
+ UNIT_ASSERT_EQUAL(yfts_read(fileTree()), nullptr);
}
class TTempDirWithLostAccess: public TTempDir {
diff --git a/util/folder/iterator.h b/util/folder/iterator.h
index 04a254c3bb..69e025b9c4 100644
--- a/util/folder/iterator.h
+++ b/util/folder/iterator.h
@@ -58,7 +58,7 @@ public:
inline void Init(int opts) noexcept {
FtsOptions = opts | FTS_NOCHDIR;
MaxLevel = Max<size_t>();
- Cmp = nullptr;
+ Cmp = nullptr;
}
};
@@ -67,7 +67,7 @@ public:
, Path_(path)
{
Trees_[0] = Path_.begin();
- Trees_[1] = nullptr;
+ Trees_[1] = nullptr;
ClearLastSystemError();
FileTree_.Reset(yfts_open(Trees_, Options_.FtsOptions, Options_.Cmp));
diff --git a/util/folder/iterator_ut.cpp b/util/folder/iterator_ut.cpp
index 2dccaadff1..936becd139 100644
--- a/util/folder/iterator_ut.cpp
+++ b/util/folder/iterator_ut.cpp
@@ -11,8 +11,8 @@
static TString JoinWithNewline(const TVector<TString>& strings) {
TStringStream ss;
- for (const auto& string : strings) {
- ss << string << "\n";
+ for (const auto& string : strings) {
+ ss << string << "\n";
}
return ss.Str();
}
diff --git a/util/folder/path.cpp b/util/folder/path.cpp
index 309fed0446..bfe0c67d68 100644
--- a/util/folder/path.cpp
+++ b/util/folder/path.cpp
@@ -1,15 +1,15 @@
-#include "dirut.h"
+#include "dirut.h"
#include "path.h"
#include "pathsplit.h"
-#include <util/generic/yexception.h>
+#include <util/generic/yexception.h>
#include <util/string/cast.h>
-#include <util/system/compiler.h>
-#include <util/system/file.h>
+#include <util/system/compiler.h>
+#include <util/system/file.h>
#include <util/system/fs.h>
struct TFsPath::TSplit: public TAtomicRefCount<TSplit>, public TPathSplit {
- inline TSplit(const TStringBuf path)
+ inline TSplit(const TStringBuf path)
: TPathSplit(path)
{
}
@@ -187,7 +187,7 @@ TFsPath::TSplit& TFsPath::GetSplit() const {
}
static Y_FORCE_INLINE void VerifyPath(const TStringBuf path) {
- Y_VERIFY(!path.Contains('\0'), "wrong format of TFsPath");
+ Y_VERIFY(!path.Contains('\0'), "wrong format of TFsPath");
}
TFsPath::TFsPath() {
@@ -199,7 +199,7 @@ TFsPath::TFsPath(const TString& path)
VerifyPath(Path_);
}
-TFsPath::TFsPath(const TStringBuf path)
+TFsPath::TFsPath(const TStringBuf path)
: Path_(ToString(path))
{
VerifyPath(Path_);
@@ -231,19 +231,19 @@ struct TClosedir {
void TFsPath::ListNames(TVector<TString>& children) const {
CheckDefined();
THolder<DIR, TClosedir> dir(opendir(this->c_str()));
- if (!dir) {
+ if (!dir) {
ythrow TIoSystemError() << "failed to opendir " << Path_;
- }
-
+ }
+
for (;;) {
struct dirent de;
struct dirent* ok;
- // TODO(yazevnul|IGNIETFERRO-1070): remove these macroses by replacing `readdir_r` with proper
- // alternative
- Y_PRAGMA_DIAGNOSTIC_PUSH
- Y_PRAGMA_NO_DEPRECATED
+ // TODO(yazevnul|IGNIETFERRO-1070): remove these macroses by replacing `readdir_r` with proper
+ // alternative
+ Y_PRAGMA_DIAGNOSTIC_PUSH
+ Y_PRAGMA_NO_DEPRECATED
int r = readdir_r(dir.Get(), &de, &ok);
- Y_PRAGMA_DIAGNOSTIC_POP
+ Y_PRAGMA_DIAGNOSTIC_POP
if (r != 0) {
ythrow TIoSystemError() << "failed to readdir " << Path_;
}
@@ -278,8 +278,8 @@ bool TFsPath::Contains(const TString& component) const {
void TFsPath::List(TVector<TFsPath>& files) const {
TVector<TString> names;
ListNames(names);
- for (auto& name : names) {
- files.push_back(Child(name));
+ for (auto& name : names) {
+ files.push_back(Child(name));
}
}
@@ -409,8 +409,8 @@ void TFsPath::ForceDelete() const {
if (stat.IsDir()) {
TVector<TFsPath> children;
List(children);
- for (auto& i : children) {
- i.ForceDelete();
+ for (auto& i : children) {
+ i.ForceDelete();
}
::rmdir(this->c_str());
} else {
@@ -467,21 +467,21 @@ const TPathSplit& TFsPath::PathSplit() const {
}
template <>
-void Out<TFsPath>(IOutputStream& os, const TFsPath& f) {
+void Out<TFsPath>(IOutputStream& os, const TFsPath& f) {
os << f.GetPath();
}
template <>
-TFsPath FromStringImpl<TFsPath>(const char* s, size_t len) {
- return TFsPath{TStringBuf{s, len}};
-}
-
-template <>
-bool TryFromStringImpl(const char* s, size_t len, TFsPath& result) {
- try {
- result = TStringBuf{s, len};
- return true;
+TFsPath FromStringImpl<TFsPath>(const char* s, size_t len) {
+ return TFsPath{TStringBuf{s, len}};
+}
+
+template <>
+bool TryFromStringImpl(const char* s, size_t len, TFsPath& result) {
+ try {
+ result = TStringBuf{s, len};
+ return true;
} catch (std::exception&) {
- return false;
- }
-}
+ return false;
+ }
+}
diff --git a/util/folder/path.h b/util/folder/path.h
index 9a85acc637..2fb4d6b4ef 100644
--- a/util/folder/path.h
+++ b/util/folder/path.h
@@ -3,15 +3,15 @@
#include "fwd.h"
#include "pathsplit.h"
-#include <util/generic/ptr.h>
-#include <util/generic/strbuf.h>
+#include <util/generic/ptr.h>
+#include <util/generic/strbuf.h>
#include <util/generic/string.h>
-#include <util/generic/vector.h>
-#include <util/string/cast.h>
+#include <util/generic/vector.h>
+#include <util/string/cast.h>
#include <util/system/fstat.h>
#include <util/system/platform.h>
#include <util/system/sysstat.h>
-#include <util/system/yassert.h>
+#include <util/system/yassert.h>
#include <utility>
@@ -26,7 +26,7 @@ private:
public:
TFsPath();
TFsPath(const TString& path);
- TFsPath(const TStringBuf path);
+ TFsPath(const TStringBuf path);
TFsPath(const char* path);
TFsPath(const std::string& path)
diff --git a/util/folder/path_ut.cpp b/util/folder/path_ut.cpp
index 7c8f12865a..e6a3451016 100644
--- a/util/folder/path_ut.cpp
+++ b/util/folder/path_ut.cpp
@@ -39,7 +39,7 @@ namespace {
};
TTestDirectory::TTestDirectory(const TString& name) {
- Y_VERIFY(name.length() > 0, "have to specify name");
+ Y_VERIFY(name.length() > 0, "have to specify name");
Y_VERIFY(name.find('.') == TString::npos, "must be simple name");
Y_VERIFY(name.find('/') == TString::npos, "must be simple name");
Y_VERIFY(name.find('\\') == TString::npos, "must be simple name");
@@ -54,8 +54,8 @@ namespace {
}
}
-Y_UNIT_TEST_SUITE(TFsPathTests) {
- Y_UNIT_TEST(TestMkDirs) {
+Y_UNIT_TEST_SUITE(TFsPathTests) {
+ Y_UNIT_TEST(TestMkDirs) {
const TFsPath path = "a/b/c/d/e/f";
path.ForceDelete();
TFsPath current = path;
@@ -77,7 +77,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
}
}
- Y_UNIT_TEST(MkDirFreak) {
+ Y_UNIT_TEST(MkDirFreak) {
TFsPath path;
UNIT_ASSERT_EXCEPTION(path.MkDir(), TIoException);
UNIT_ASSERT_EXCEPTION(path.MkDirs(), TIoException);
@@ -86,7 +86,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
path.MkDirs();
}
- Y_UNIT_TEST(Parent) {
+ Y_UNIT_TEST(Parent) {
#ifdef _win_
UNIT_ASSERT_VALUES_EQUAL(TFsPath("\\etc/passwd").Parent(), TFsPath("\\etc"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("\\etc").Parent(), TFsPath("\\"));
@@ -117,7 +117,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
#endif
}
- Y_UNIT_TEST(GetName) {
+ Y_UNIT_TEST(GetName) {
TTestDirectory d("GetName");
UNIT_ASSERT_VALUES_EQUAL(TString("dfgh"), d.Child("dfgh").GetName());
@@ -129,7 +129,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
#endif
}
- Y_UNIT_TEST(GetExtension) {
+ Y_UNIT_TEST(GetExtension) {
TTestDirectory d("GetExtension");
UNIT_ASSERT_VALUES_EQUAL("", d.Child("a").GetExtension());
UNIT_ASSERT_VALUES_EQUAL("", d.Child(".a").GetExtension());
@@ -138,7 +138,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
UNIT_ASSERT_VALUES_EQUAL("zlib", d.Child("file.ylib.zlib").GetExtension());
}
- Y_UNIT_TEST(TestRename) {
+ Y_UNIT_TEST(TestRename) {
TTestDirectory xx("TestRename");
TFsPath f1 = xx.Child("f1");
TFsPath f2 = xx.Child("f2");
@@ -148,7 +148,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
UNIT_ASSERT(f2.Exists());
}
- Y_UNIT_TEST(TestForceRename) {
+ Y_UNIT_TEST(TestForceRename) {
TTestDirectory xx("TestForceRename");
TFsPath fMain = xx.Child("main");
@@ -168,12 +168,12 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
UNIT_ASSERT(xx.Child("main1").Child("f1").Child("f1child").Exists());
}
- Y_UNIT_TEST(TestRenameFail) {
+ Y_UNIT_TEST(TestRenameFail) {
UNIT_ASSERT_EXCEPTION(TFsPath("sfsfsfsdfsfsdfdf").RenameTo("sdfsdf"), TIoException);
}
#ifndef _win_
- Y_UNIT_TEST(TestRealPath) {
+ Y_UNIT_TEST(TestRealPath) {
UNIT_ASSERT(TFsPath(".").RealPath().IsDirectory());
TTestDirectory td("TestRealPath");
@@ -190,7 +190,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
}
#endif
- Y_UNIT_TEST(TestSlashesAndBasename) {
+ Y_UNIT_TEST(TestSlashesAndBasename) {
TFsPath p("/db/BASE/primus121-025-1380131338//");
UNIT_ASSERT_VALUES_EQUAL(p.Basename(), TString("primus121-025-1380131338"));
TFsPath testP = p / "test";
@@ -201,7 +201,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
#endif
}
- Y_UNIT_TEST(TestSlashesAndBasenameWin) {
+ Y_UNIT_TEST(TestSlashesAndBasenameWin) {
TFsPath p("\\db\\BASE\\primus121-025-1380131338\\\\");
TFsPath testP = p / "test";
#ifdef _win_
@@ -213,7 +213,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
#endif
}
- Y_UNIT_TEST(TestSlashesAndBasenameWinDrive) {
+ Y_UNIT_TEST(TestSlashesAndBasenameWinDrive) {
TFsPath p("C:\\db\\BASE\\primus121-025-1380131338\\\\");
TFsPath testP = p / "test";
#ifdef _win_
@@ -225,7 +225,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
#endif
}
- Y_UNIT_TEST(TestList) {
+ Y_UNIT_TEST(TestList) {
TTestDirectory td("TestList-dir");
TFsPath dir = td.GetFsPath();
@@ -249,7 +249,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
}
#ifdef _unix_
- Y_UNIT_TEST(MkDirMode) {
+ Y_UNIT_TEST(MkDirMode) {
TTestDirectory td("MkDirMode");
TFsPath subDir = td.Child("subdir");
const int mode = MODE0775;
@@ -263,11 +263,11 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
}
#endif
- Y_UNIT_TEST(Cwd) {
+ Y_UNIT_TEST(Cwd) {
UNIT_ASSERT_VALUES_EQUAL(TFsPath::Cwd().RealPath(), TFsPath(".").RealPath());
}
- Y_UNIT_TEST(TestSubpathOf) {
+ Y_UNIT_TEST(TestSubpathOf) {
UNIT_ASSERT(TFsPath("/a/b/c/d").IsSubpathOf("/a/b"));
UNIT_ASSERT(TFsPath("/a").IsSubpathOf("/"));
@@ -334,7 +334,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
#endif
}
- Y_UNIT_TEST(TestRelativePath) {
+ Y_UNIT_TEST(TestRelativePath) {
UNIT_ASSERT_VALUES_EQUAL(TFsPath("/a/b/c/d").RelativePath(TFsPath("/a/b")), TFsPath("c/d"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("/a/b/c/d").RelativePath(TFsPath("/a/b/e/f")), TFsPath("../../c/d"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("/").RelativePath(TFsPath("/")), TFsPath());
@@ -345,7 +345,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
UNIT_ASSERT_EXCEPTION(TFsPath("a/b/c").RelativePath(TFsPath("d/e")), TIoException);
}
- Y_UNIT_TEST(TestUndefined) {
+ Y_UNIT_TEST(TestUndefined) {
UNIT_ASSERT_VALUES_EQUAL(TFsPath(), TFsPath(""));
UNIT_ASSERT_VALUES_EQUAL(TFsPath(), TFsPath().Fix());
@@ -393,7 +393,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
UNIT_ASSERT(!TFsPath().Stat(stat));
}
- Y_UNIT_TEST(TestJoinFsPaths) {
+ Y_UNIT_TEST(TestJoinFsPaths) {
#ifdef _win_
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a\\b", "c\\d"), "a\\b\\c\\d");
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a\\b", "..\\c"), "a\\b\\..\\c");
@@ -410,23 +410,23 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a/b", ""), "a/b");
#endif
}
-
- Y_UNIT_TEST(TestStringCast) {
- TFsPath pathOne;
- UNIT_ASSERT(TryFromString<TFsPath>("/a/b", pathOne));
- UNIT_ASSERT_VALUES_EQUAL(pathOne, TFsPath{"/a/b"});
-
- TFsPath pathTwo;
- UNIT_ASSERT_NO_EXCEPTION(TryFromString<TFsPath>("/a/b", pathTwo));
-
- UNIT_ASSERT_VALUES_EQUAL(FromString<TFsPath>("/a/b"), TFsPath{"/a/b"});
-
- TFsPath pathThree{"/a/b"};
- UNIT_ASSERT_VALUES_EQUAL(ToString(pathThree), "/a/b");
- }
+
+ Y_UNIT_TEST(TestStringCast) {
+ TFsPath pathOne;
+ UNIT_ASSERT(TryFromString<TFsPath>("/a/b", pathOne));
+ UNIT_ASSERT_VALUES_EQUAL(pathOne, TFsPath{"/a/b"});
+
+ TFsPath pathTwo;
+ UNIT_ASSERT_NO_EXCEPTION(TryFromString<TFsPath>("/a/b", pathTwo));
+
+ UNIT_ASSERT_VALUES_EQUAL(FromString<TFsPath>("/a/b"), TFsPath{"/a/b"});
+
+ TFsPath pathThree{"/a/b"};
+ UNIT_ASSERT_VALUES_EQUAL(ToString(pathThree), "/a/b");
+ }
#ifdef _unix_
- Y_UNIT_TEST(TestRemoveSymlinkToDir) {
+ Y_UNIT_TEST(TestRemoveSymlinkToDir) {
TTempDir tempDir;
TFsPath tempDirPath(tempDir());
@@ -449,7 +449,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
UNIT_ASSERT(NFs::Exists(originDir));
}
- Y_UNIT_TEST(TestRemoveSymlinkToFile) {
+ Y_UNIT_TEST(TestRemoveSymlinkToFile) {
TTempDir tempDir;
TFsPath tempDirPath(tempDir());
@@ -472,7 +472,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
UNIT_ASSERT(NFs::Exists(originDir));
}
- Y_UNIT_TEST(TestRemoveDirWithSymlinkToDir) {
+ Y_UNIT_TEST(TestRemoveDirWithSymlinkToDir) {
TTempDir tempDir;
TFsPath tempDirPath(tempDir());
@@ -499,7 +499,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
UNIT_ASSERT(NFs::Exists(originDir));
}
- Y_UNIT_TEST(TestRemoveDirWithSymlinkToFile) {
+ Y_UNIT_TEST(TestRemoveDirWithSymlinkToFile) {
TTempDir tempDir;
TFsPath tempDirPath(tempDir());
diff --git a/util/folder/pathsplit.cpp b/util/folder/pathsplit.cpp
index c2abc13141..81d439a727 100644
--- a/util/folder/pathsplit.cpp
+++ b/util/folder/pathsplit.cpp
@@ -16,7 +16,7 @@ static inline size_t ToReserve(const T& t) {
return ret;
}
-void TPathSplitTraitsUnix::DoParseFirstPart(const TStringBuf part) {
+void TPathSplitTraitsUnix::DoParseFirstPart(const TStringBuf part) {
if (part == TStringBuf(".")) {
push_back(TStringBuf("."));
@@ -30,7 +30,7 @@ void TPathSplitTraitsUnix::DoParseFirstPart(const TStringBuf part) {
DoParsePart(part);
}
-void TPathSplitTraitsUnix::DoParsePart(const TStringBuf part0) {
+void TPathSplitTraitsUnix::DoParsePart(const TStringBuf part0) {
DoAppendHint(part0.size() / 8);
TStringBuf next(part0);
@@ -43,7 +43,7 @@ void TPathSplitTraitsUnix::DoParsePart(const TStringBuf part0) {
AppendComponent(next);
}
-void TPathSplitTraitsWindows::DoParseFirstPart(const TStringBuf part0) {
+void TPathSplitTraitsWindows::DoParseFirstPart(const TStringBuf part0) {
TStringBuf part(part0);
if (part == TStringBuf(".")) {
@@ -64,7 +64,7 @@ void TPathSplitTraitsWindows::DoParseFirstPart(const TStringBuf part0) {
DoParsePart(part);
}
-void TPathSplitTraitsWindows::DoParsePart(const TStringBuf part0) {
+void TPathSplitTraitsWindows::DoParsePart(const TStringBuf part0) {
DoAppendHint(part0.size() / 8);
size_t pos = 0;
@@ -106,7 +106,7 @@ TString TPathSplitStore::DoReconstruct(const TStringBuf slash) const {
return r;
}
-void TPathSplitStore::AppendComponent(const TStringBuf comp) {
+void TPathSplitStore::AppendComponent(const TStringBuf comp) {
if (!comp || comp == TStringBuf(".")) {
; // ignore
} else if (comp == TStringBuf("..") && !empty() && back() != TStringBuf("..")) {
@@ -122,7 +122,7 @@ TStringBuf TPathSplitStore::Extension() const {
}
template <>
-void Out<TPathSplit>(IOutputStream& o, const TPathSplit& ps) {
+void Out<TPathSplit>(IOutputStream& o, const TPathSplit& ps) {
o << ps.Reconstruct();
}
@@ -134,7 +134,7 @@ TString JoinPaths(const TPathSplit& p1, const TPathSplit& p2) {
return TPathSplit(p1).AppendMany(p2.begin(), p2.end()).Reconstruct();
}
-TStringBuf CutExtension(const TStringBuf fileName) {
+TStringBuf CutExtension(const TStringBuf fileName) {
if (fileName.empty()) {
return fileName;
}
diff --git a/util/folder/pathsplit.h b/util/folder/pathsplit.h
index c7f5d55197..d134338e35 100644
--- a/util/folder/pathsplit.h
+++ b/util/folder/pathsplit.h
@@ -10,7 +10,7 @@ struct TPathSplitStore: public TVector<TStringBuf> {
TStringBuf Drive;
bool IsAbsolute = false;
- void AppendComponent(const TStringBuf comp);
+ void AppendComponent(const TStringBuf comp);
TStringBuf Extension() const;
protected:
@@ -22,41 +22,41 @@ protected:
};
struct TPathSplitTraitsUnix: public TPathSplitStore {
- static constexpr char MainPathSep = '/';
+ static constexpr char MainPathSep = '/';
inline TString Reconstruct() const {
return DoReconstruct(TStringBuf("/"));
}
- static constexpr bool IsPathSep(const char c) noexcept {
+ static constexpr bool IsPathSep(const char c) noexcept {
return c == '/';
}
- static inline bool IsAbsolutePath(const TStringBuf path) noexcept {
+ static inline bool IsAbsolutePath(const TStringBuf path) noexcept {
return path && IsPathSep(path[0]);
}
- void DoParseFirstPart(const TStringBuf part);
- void DoParsePart(const TStringBuf part);
+ void DoParseFirstPart(const TStringBuf part);
+ void DoParsePart(const TStringBuf part);
};
struct TPathSplitTraitsWindows: public TPathSplitStore {
- static constexpr char MainPathSep = '\\';
+ static constexpr char MainPathSep = '\\';
inline TString Reconstruct() const {
return DoReconstruct(TStringBuf("\\"));
}
- static constexpr bool IsPathSep(char c) noexcept {
+ static constexpr bool IsPathSep(char c) noexcept {
return c == '/' || c == '\\';
}
- static inline bool IsAbsolutePath(const TStringBuf path) noexcept {
+ static inline bool IsAbsolutePath(const TStringBuf path) noexcept {
return path && (IsPathSep(path[0]) || (path.size() > 1 && path[1] == ':' && IsAsciiAlpha(path[0]) && (path.size() == 2 || IsPathSep(path[2]))));
}
- void DoParseFirstPart(const TStringBuf part);
- void DoParsePart(const TStringBuf part);
+ void DoParseFirstPart(const TStringBuf part);
+ void DoParsePart(const TStringBuf part);
};
#if defined(_unix_)
@@ -70,7 +70,7 @@ class TPathSplitBase: public TTraits {
public:
inline TPathSplitBase() = default;
- inline TPathSplitBase(const TStringBuf part) {
+ inline TPathSplitBase(const TStringBuf part) {
this->ParseFirstPart(part);
}
@@ -80,13 +80,13 @@ public:
return *this;
}
- inline TPathSplitBase& ParseFirstPart(const TStringBuf part) {
+ inline TPathSplitBase& ParseFirstPart(const TStringBuf part) {
this->DoParseFirstPart(part);
return *this;
}
- inline TPathSplitBase& ParsePart(const TStringBuf part) {
+ inline TPathSplitBase& ParsePart(const TStringBuf part) {
this->DoParsePart(part);
return *this;
@@ -110,4 +110,4 @@ using TPathSplitWindows = TPathSplitBase<TPathSplitTraitsWindows>;
TString JoinPaths(const TPathSplit& p1, const TPathSplit& p2);
-TStringBuf CutExtension(const TStringBuf fileName);
+TStringBuf CutExtension(const TStringBuf fileName);
diff --git a/util/folder/pathsplit_ut.cpp b/util/folder/pathsplit_ut.cpp
index baa23c9f77..0e97afd0d0 100644
--- a/util/folder/pathsplit_ut.cpp
+++ b/util/folder/pathsplit_ut.cpp
@@ -63,50 +63,50 @@
#define TRUE_ONLY_WIN false
#endif
-Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
- Y_UNIT_TEST(Empty) {
+Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
+ Y_UNIT_TEST(Empty) {
PSUF(TPathSplit)
ps;
PS_CHECK(ps);
UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
}
- Y_UNIT_TEST(Relative) {
+ Y_UNIT_TEST(Relative) {
PSUF(TPathSplit)
ps("some/usual/path");
PS_CHECK(ps, "some", "usual", "path");
UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
}
- Y_UNIT_TEST(Absolute) {
+ Y_UNIT_TEST(Absolute) {
PSUF(TPathSplit)
ps("/some/usual/path");
PS_CHECK(ps, "some", "usual", "path");
UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
}
- Y_UNIT_TEST(Self) {
+ Y_UNIT_TEST(Self) {
PSUF(TPathSplit)
ps(".");
PS_CHECK(ps, ".");
UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
}
- Y_UNIT_TEST(Parent) {
+ Y_UNIT_TEST(Parent) {
PSUF(TPathSplit)
ps("..");
PS_CHECK(ps, "..");
UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
}
- Y_UNIT_TEST(Root) {
+ Y_UNIT_TEST(Root) {
PSUF(TPathSplit)
ps("/");
PS_CHECK(ps);
UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
}
- Y_UNIT_TEST(Reconstruct) {
+ Y_UNIT_TEST(Reconstruct) {
PSUF(TPathSplit)
ps("some/usual/path/../../other/././//path");
#ifdef _win_
@@ -123,7 +123,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
#endif
}
- Y_UNIT_TEST(ParseFirstPart) {
+ Y_UNIT_TEST(ParseFirstPart) {
PSUF(TPathSplit)
ps;
ps.ParseFirstPart("some/usual/path");
@@ -136,7 +136,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
}
- Y_UNIT_TEST(ParsePart) {
+ Y_UNIT_TEST(ParsePart) {
PSUF(TPathSplit)
ps("some/usual/path");
ps.ParsePart("sub/path");
@@ -149,7 +149,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
}
- Y_UNIT_TEST(ParsePartSelf) {
+ Y_UNIT_TEST(ParsePartSelf) {
PSUF(TPathSplit)
ps("some/usual/path");
ps.ParsePart(".");
@@ -160,7 +160,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
PS_CHECK(ps, "some", "usual", "path");
}
- Y_UNIT_TEST(ParsePartParent) {
+ Y_UNIT_TEST(ParsePartParent) {
PSUF(TPathSplit)
ps("some/usual/path");
ps.ParsePart("..");
@@ -181,7 +181,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
}
- Y_UNIT_TEST(ParsePartOverflow) {
+ Y_UNIT_TEST(ParsePartOverflow) {
PSUF(TPathSplit)
ps("some/usual/path");
ps.ParsePart("../../../../..");
@@ -194,7 +194,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
}
- Y_UNIT_TEST(WinRelative) {
+ Y_UNIT_TEST(WinRelative) {
PSUF(TPathSplit)
ps("some\\usual\\path");
#ifdef _win_
@@ -205,7 +205,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
}
- Y_UNIT_TEST(WinAbsolute) {
+ Y_UNIT_TEST(WinAbsolute) {
PSUF(TPathSplit)
ps("\\some\\usual\\path");
#ifdef _win_
@@ -236,7 +236,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
UNIT_ASSERT_EQUAL(psDrive2.IsAbsolute, TRUE_ONLY_WIN);
}
- Y_UNIT_TEST(WinRoot) {
+ Y_UNIT_TEST(WinRoot) {
PSUF(TPathSplit)
ps("\\");
#ifdef _win_
@@ -257,7 +257,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
UNIT_ASSERT_EQUAL(psDrive.IsAbsolute, TRUE_ONLY_WIN);
}
- Y_UNIT_TEST(WinReconstruct) {
+ Y_UNIT_TEST(WinReconstruct) {
PSUF(TPathSplit)
ps("some\\usual\\path\\..\\..\\other\\.\\.\\\\\\path");
#ifdef _win_
@@ -274,7 +274,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
#endif
}
- Y_UNIT_TEST(WinParseFirstPart) {
+ Y_UNIT_TEST(WinParseFirstPart) {
PSUF(TPathSplit)
ps;
ps.ParseFirstPart("some\\usual\\path");
@@ -295,7 +295,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
UNIT_ASSERT_EQUAL(ps.IsAbsolute, TRUE_ONLY_WIN);
}
- Y_UNIT_TEST(WinParsePart) {
+ Y_UNIT_TEST(WinParsePart) {
PSUF(TPathSplit)
ps("some\\usual\\path");
ps.ParsePart("sub\\path");
@@ -317,7 +317,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
}
#ifdef _win_
- Y_UNIT_TEST(WinParsePartSelf) {
+ Y_UNIT_TEST(WinParsePartSelf) {
PSUF(TPathSplit)
ps("some\\usual\\path");
ps.ParsePart(".");
@@ -328,7 +328,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
PS_CHECK(ps, "some", "usual", "path");
}
- Y_UNIT_TEST(WinParsePartParent) {
+ Y_UNIT_TEST(WinParsePartParent) {
PSUF(TPathSplit)
ps("some\\usual\\path");
ps.ParsePart("..");
@@ -355,7 +355,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
UNIT_ASSERT_EQUAL(ps.Drive, "C:");
}
- Y_UNIT_TEST(WinParsePartOverflow) {
+ Y_UNIT_TEST(WinParsePartOverflow) {
PSUF(TPathSplit)
ps("some\\usual\\path");
ps.ParsePart("..\\..\\..\\..\\..");
@@ -375,7 +375,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
}
#endif
- Y_UNIT_TEST(WinMixed) {
+ Y_UNIT_TEST(WinMixed) {
PSUF(TPathSplit)
ps("some\\usual/path");
#ifdef _win_
@@ -386,7 +386,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
}
- Y_UNIT_TEST(WinParsePartMixed) {
+ Y_UNIT_TEST(WinParsePartMixed) {
PSUF(TPathSplit)
ps("some\\usual/path");
ps.ParsePart("sub/sub\\path");
@@ -398,7 +398,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
}
- Y_UNIT_TEST(BeginWithSelf) {
+ Y_UNIT_TEST(BeginWithSelf) {
PSUF(TPathSplit)
ps("./some/usual/path");
PS_CHECK(ps, "some", "usual", "path");
@@ -409,7 +409,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
#endif
}
- Y_UNIT_TEST(BeginWithParent) {
+ Y_UNIT_TEST(BeginWithParent) {
PSUF(TPathSplit)
ps("../some/usual/path");
PS_CHECK(ps, "..", "some", "usual", "path");
@@ -420,14 +420,14 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
#endif
}
- Y_UNIT_TEST(InOut) {
+ Y_UNIT_TEST(InOut) {
PSUF(TPathSplit)
ps("path/..");
PS_CHECK(ps);
UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "");
}
- Y_UNIT_TEST(OutIn) {
+ Y_UNIT_TEST(OutIn) {
PSUF(TPathSplit)
ps("../path");
PS_CHECK(ps, "..", "path");
@@ -439,14 +439,14 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
}
}
-Y_UNIT_TEST_SUITE(PSUF(PathSplitTraits)) {
- Y_UNIT_TEST(IsPathSep) {
+Y_UNIT_TEST_SUITE(PSUF(PathSplitTraits)) {
+ Y_UNIT_TEST(IsPathSep) {
UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsPathSep('/'), true);
UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsPathSep('\\'), TRUE_ONLY_WIN);
UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsPathSep(' '), false);
}
- Y_UNIT_TEST(IsAbsolutePath) {
+ Y_UNIT_TEST(IsAbsolutePath) {
UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath(""), false);
UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("/"), true);
UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("some/usual/path"), false);
@@ -457,7 +457,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplitTraits)) {
UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("/.."), true);
}
- Y_UNIT_TEST(WinIsAbsolutePath) {
+ Y_UNIT_TEST(WinIsAbsolutePath) {
UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("somepath"), false);
UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("\\"), TRUE_ONLY_WIN);
UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("\\somepath"), TRUE_ONLY_WIN);
diff --git a/util/folder/tempdir.cpp b/util/folder/tempdir.cpp
index fdf66d5de3..6fdf8f753c 100644
--- a/util/folder/tempdir.cpp
+++ b/util/folder/tempdir.cpp
@@ -16,7 +16,7 @@ TTempDir::TTempDir(const char* prefix, TCreationToken)
{
char tempDir[MAX_PATH];
if (MakeTempDir(tempDir, prefix) != 0) {
- ythrow TSystemError() << "Can't create temporary directory";
+ ythrow TSystemError() << "Can't create temporary directory";
}
TempDir = tempDir;
}
diff --git a/util/generic/adaptor_ut.cpp b/util/generic/adaptor_ut.cpp
index 1a14b942b4..721f849f93 100644
--- a/util/generic/adaptor_ut.cpp
+++ b/util/generic/adaptor_ut.cpp
@@ -32,8 +32,8 @@ struct TState {
}
};
-Y_UNIT_TEST_SUITE(TReverseAdaptor) {
- Y_UNIT_TEST(ReadTest) {
+Y_UNIT_TEST_SUITE(TReverseAdaptor) {
+ Y_UNIT_TEST(ReadTest) {
TVector<int> cont = {1, 2, 3};
TVector<int> etalon = {3, 2, 1};
size_t idx = 0;
@@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TReverseAdaptor) {
}
}
- Y_UNIT_TEST(WriteTest) {
+ Y_UNIT_TEST(WriteTest) {
TVector<int> cont = {1, 2, 3};
TVector<int> etalon = {3, 6, 9};
size_t idx = 0;
@@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(TReverseAdaptor) {
}
}
- Y_UNIT_TEST(InnerTypeTest) {
+ Y_UNIT_TEST(InnerTypeTest) {
using TStub = TVector<int>;
TStub stub;
const TStub cstub;
@@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TReverseAdaptor) {
UNIT_ASSERT_TYPES_EQUAL(decltype(Reversed(cstub)), TReverseRange<const TStub&>);
}
- Y_UNIT_TEST(CopyMoveTest) {
+ Y_UNIT_TEST(CopyMoveTest) {
TState lvalue;
const TState clvalue;
UNIT_ASSERT_NO_EXCEPTION(Reversed(lvalue));
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h
index fce4c9c695..badfb88993 100644
--- a/util/generic/algorithm.h
+++ b/util/generic/algorithm.h
@@ -181,7 +181,7 @@ static inline bool AnyOf(const C& c, P pred) {
template <class I, class P>
static inline auto FindIfPtr(I f, I l, P pred) -> decltype(&*f) {
I found = FindIf(f, l, pred);
- return (found != l) ? &*found : nullptr;
+ return (found != l) ? &*found : nullptr;
}
template <class C, class P>
@@ -218,16 +218,16 @@ inline bool EqualToOneOf(const T& x, const U& y, const Other&... other) {
return x == y || EqualToOneOf(x, other...);
}
-template <typename T>
-static inline size_t CountOf(const T&) {
- return 0;
-}
-
-template <typename T, typename U, typename... Other>
-static inline size_t CountOf(const T& x, const U& y, const Other&... other) {
- return static_cast<size_t>(x == y) + CountOf(x, other...);
-}
-
+template <typename T>
+static inline size_t CountOf(const T&) {
+ return 0;
+}
+
+template <typename T, typename U, typename... Other>
+static inline size_t CountOf(const T& x, const U& y, const Other&... other) {
+ return static_cast<size_t>(x == y) + CountOf(x, other...);
+}
+
template <class I>
static inline void PushHeap(I f, I l) {
std::push_heap(f, l);
@@ -438,7 +438,7 @@ static inline void Fill(I f, I l, const T& v) {
std::fill(f, l, v);
}
-template <typename I, typename S, typename T>
+template <typename I, typename S, typename T>
static inline I FillN(I f, S n, const T& v) {
return std::fill_n(f, n, v);
}
diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp
index fc2a05efb9..8d732fcc0c 100644
--- a/util/generic/algorithm_ut.cpp
+++ b/util/generic/algorithm_ut.cpp
@@ -6,8 +6,8 @@
static auto isOne = [](char c) { return c == '1'; };
-Y_UNIT_TEST_SUITE(TAlgorithm) {
- Y_UNIT_TEST(AnyTest) {
+Y_UNIT_TEST_SUITE(TAlgorithm) {
+ Y_UNIT_TEST(AnyTest) {
UNIT_ASSERT(0 == AnyOf(TStringBuf("00"), isOne));
UNIT_ASSERT(1 == AnyOf(TStringBuf("01"), isOne));
UNIT_ASSERT(1 == AnyOf(TStringBuf("10"), isOne));
@@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT(1 == AnyOf(array01, isOne));
}
- Y_UNIT_TEST(AllOfTest) {
+ Y_UNIT_TEST(AllOfTest) {
UNIT_ASSERT(0 == AllOf(TStringBuf("00"), isOne));
UNIT_ASSERT(0 == AllOf(TStringBuf("01"), isOne));
UNIT_ASSERT(0 == AllOf(TStringBuf("10"), isOne));
@@ -33,7 +33,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT(1 == AllOf(array11, isOne));
}
- Y_UNIT_TEST(CountIfTest) {
+ Y_UNIT_TEST(CountIfTest) {
UNIT_ASSERT(3 == CountIf(TStringBuf("____1________1____1_______"), isOne));
UNIT_ASSERT(5 == CountIf(TStringBuf("1____1________1____1_______1"), isOne));
UNIT_ASSERT(0 == CountIf(TStringBuf("___________"), isOne));
@@ -68,40 +68,40 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
void operator=(const TStrokaNoCopy&);
};
- Y_UNIT_TEST(CountOfTest) {
- UNIT_ASSERT_VALUES_EQUAL(CountOf(1, 2), 0);
- UNIT_ASSERT_VALUES_EQUAL(CountOf(1, 1), 1);
- UNIT_ASSERT_VALUES_EQUAL(CountOf(2, 4, 5), 0);
- UNIT_ASSERT_VALUES_EQUAL(CountOf(2, 4, 2), 1);
- UNIT_ASSERT_VALUES_EQUAL(CountOf(3, 3, 3), 2);
-
- // Checking comparison of different types.
- UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'x', 'y', 'z'), 0);
- UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'a', 'b', 'c', 0x61), 2);
- UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'a', 'b', 'c', 0x61ll), 2);
-
+ Y_UNIT_TEST(CountOfTest) {
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(1, 2), 0);
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(1, 1), 1);
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(2, 4, 5), 0);
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(2, 4, 2), 1);
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(3, 3, 3), 2);
+
+ // Checking comparison of different types.
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'x', 'y', 'z'), 0);
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'a', 'b', 'c', 0x61), 2);
+ UNIT_ASSERT_VALUES_EQUAL(CountOf(0x61, 'a', 'b', 'c', 0x61ll), 2);
+
// TString and const char *
UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), "123", "poi"), 0);
UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), "123", "poi", "xyz"), 1);
-
+
// TString and TStringBuf
UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi")), 0);
UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi"),
TStringBuf("xyz")),
1);
-
- // TStringBuf and const char *
+
+ // TStringBuf and const char *
UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi"), 0);
UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi", "xyz"), 1);
-
+
// TStringBuf and TString
UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi")), 0);
UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi"),
TString("xyz")),
1);
- }
-
- Y_UNIT_TEST(EqualToOneOfTest) {
+ }
+
+ Y_UNIT_TEST(EqualToOneOfTest) {
UNIT_ASSERT(1 == EqualToOneOf(1, 1, 2));
UNIT_ASSERT(1 == EqualToOneOf(2, 1, 2));
UNIT_ASSERT(0 == EqualToOneOf(3, 1, 2));
@@ -141,7 +141,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
template <class TTestConstPtr>
void TestFindIfPtrFoundValue(int j, TTestConstPtr root) {
if (j == 3) {
- UNIT_ASSERT(root == nullptr);
+ UNIT_ASSERT(root == nullptr);
} else if (j == 4) {
UNIT_ASSERT(root && *root == 2);
} else {
@@ -203,7 +203,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(FindIndexTest) {
+ Y_UNIT_TEST(FindIndexTest) {
TVectorNoCopy v;
v.push_back(1);
v.push_back(2);
@@ -247,7 +247,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_EQUAL(NPOS, FindIndexIf(empty, [](int x) { return x == 3; }));
}
- Y_UNIT_TEST(SortUniqueTest) {
+ Y_UNIT_TEST(SortUniqueTest) {
{
TVector<TString> v;
SortUnique(v);
@@ -266,21 +266,21 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(EraseTest) {
+ Y_UNIT_TEST(EraseTest) {
TVector<int> data = {5, 4, 3, 2, 1, 0};
TVector<int> expected = {5, 4, 2, 1, 0};
Erase(data, 3);
UNIT_ASSERT_EQUAL(data, expected);
}
- Y_UNIT_TEST(EraseIfTest) {
+ Y_UNIT_TEST(EraseIfTest) {
TVector<int> data = {5, 4, 3, 2, 1, 0};
TVector<int> expected = {2, 1, 0};
EraseIf(data, [](int i) { return i >= 3; });
UNIT_ASSERT_EQUAL(data, expected);
}
- Y_UNIT_TEST(EraseNodesIfTest) {
+ Y_UNIT_TEST(EraseNodesIfTest) {
TMap<int, int> map{{1, 1}, {2, 2}, {3, 5}};
TMap<int, int> expectedMap{{1, 1}};
EraseNodesIf(map, [](auto p) { return p.first >= 2; });
@@ -312,7 +312,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_EQUAL(hashMultiMap, expectedHashMultiMap);
}
- Y_UNIT_TEST(NthElementTest) {
+ Y_UNIT_TEST(NthElementTest) {
{
TVector<TString> v;
NthElement(v.begin(), v.begin(), v.end());
@@ -348,7 +348,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(BinarySearchTest) {
+ Y_UNIT_TEST(BinarySearchTest) {
{
TVector<TString> v;
bool test = BinarySearch(v.begin(), v.end(), "test");
@@ -358,10 +358,10 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
{
int data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
- bool test = BinarySearch(data, data + Y_ARRAY_SIZE(data), 2);
+ bool test = BinarySearch(data, data + Y_ARRAY_SIZE(data), 2);
UNIT_ASSERT_EQUAL(test, true);
- test = BinarySearch(data, data + Y_ARRAY_SIZE(data), 10);
+ test = BinarySearch(data, data + Y_ARRAY_SIZE(data), 10);
UNIT_ASSERT_EQUAL(test, false);
}
@@ -379,7 +379,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(EqualRangeTest) {
+ Y_UNIT_TEST(EqualRangeTest) {
{
TVector<TString> v;
using PairOfVector = std::pair<TVector<TString>::iterator, TVector<TString>::iterator>;
@@ -392,11 +392,11 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
{
int data[] = {1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 5};
using PairOfInt = std::pair<int*, int*>;
- PairOfInt tmp = EqualRange(data, data + Y_ARRAY_SIZE(data), 3);
+ PairOfInt tmp = EqualRange(data, data + Y_ARRAY_SIZE(data), 3);
UNIT_ASSERT_EQUAL(tmp.second - tmp.first, 4);
UNIT_ASSERT_EQUAL(tmp.first - data, 7);
- UNIT_ASSERT_EQUAL(data + Y_ARRAY_SIZE(data) - tmp.second, 2);
+ UNIT_ASSERT_EQUAL(data + Y_ARRAY_SIZE(data) - tmp.second, 2);
}
{
@@ -416,7 +416,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(IsSortedTest) {
+ Y_UNIT_TEST(IsSortedTest) {
TVector<int> v0;
UNIT_ASSERT_VALUES_EQUAL(IsSorted(v0.begin(), v0.end()), true);
@@ -445,91 +445,91 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_VALUES_EQUAL(IsSortedBy(v3.begin(), v3.end(), std::negate<int>()), false);
}
- Y_UNIT_TEST(SortTestTwoIterators) {
+ Y_UNIT_TEST(SortTestTwoIterators) {
TVector<int> collection = {10, 2, 7};
Sort(collection.begin(), collection.end());
TVector<int> expected = {2, 7, 10};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(SortTestTwoIteratorsAndComparator) {
+ Y_UNIT_TEST(SortTestTwoIteratorsAndComparator) {
TVector<int> collection = {10, 2, 7};
Sort(collection.begin(), collection.end(), [](int l, int r) { return l > r; });
TVector<int> expected = {10, 7, 2};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(SortTestContainer) {
+ Y_UNIT_TEST(SortTestContainer) {
TVector<int> collection = {10, 2, 7};
Sort(collection);
TVector<int> expected = {2, 7, 10};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(SortTestContainerAndComparator) {
+ Y_UNIT_TEST(SortTestContainerAndComparator) {
TVector<int> collection = {10, 2, 7};
Sort(collection, [](int l, int r) { return l > r; });
TVector<int> expected = {10, 7, 2};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(StableSortTestTwoIterators) {
+ Y_UNIT_TEST(StableSortTestTwoIterators) {
TVector<int> collection = {10, 2, 7};
StableSort(collection.begin(), collection.end());
TVector<int> expected = {2, 7, 10};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(StableSortTestTwoIteratorsAndComparator) {
+ Y_UNIT_TEST(StableSortTestTwoIteratorsAndComparator) {
TVector<int> collection = {404, 101, 106, 203, 102, 205, 401};
StableSort(collection.begin(), collection.end(), [](int l, int r) { return (l / 100) < (r / 100); });
TVector<int> expected = {101, 106, 102, 203, 205, 404, 401};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(StableSortTestContainer) {
+ Y_UNIT_TEST(StableSortTestContainer) {
TVector<int> collection = {10, 2, 7};
StableSort(collection);
TVector<int> expected = {2, 7, 10};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(StableSortTestContainerAndComparator) {
+ Y_UNIT_TEST(StableSortTestContainerAndComparator) {
TVector<int> collection = {404, 101, 106, 203, 102, 205, 401};
StableSort(collection, [](int l, int r) { return (l / 100) < (r / 100); });
TVector<int> expected = {101, 106, 102, 203, 205, 404, 401};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(SortByTest) {
+ Y_UNIT_TEST(SortByTest) {
TVector<int> collection = {10, 2, 7};
SortBy(collection, [](int x) { return -x; });
TVector<int> expected = {10, 7, 2};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(StableSortByTest) {
+ Y_UNIT_TEST(StableSortByTest) {
TVector<int> collection = {404, 101, 106, 203, 102, 205, 401};
StableSortBy(collection, [](int x) { return x / 100; });
TVector<int> expected = {101, 106, 102, 203, 205, 404, 401};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(SortUniqueByTest) {
+ Y_UNIT_TEST(SortUniqueByTest) {
TVector<int> collection = {404, 101, 101, 203, 101, 203, 404};
StableSortUniqueBy(collection, [](int x) { return x / 100; });
TVector<int> expected = {101, 203, 404};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(StableSortUniqueByTest) {
+ Y_UNIT_TEST(StableSortUniqueByTest) {
TVector<int> collection = {404, 101, 106, 203, 102, 205, 401};
StableSortUniqueBy(collection, [](int x) { return x / 100; });
TVector<int> expected = {101, 203, 404};
UNIT_ASSERT_VALUES_EQUAL(collection, expected);
}
- Y_UNIT_TEST(IotaTest) {
+ Y_UNIT_TEST(IotaTest) {
TVector<int> v(10);
Iota(v.begin(), v.end(), 0);
@@ -543,7 +543,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_VALUES_EQUAL(v[9], 9);
}
- Y_UNIT_TEST(CopyNTest) {
+ Y_UNIT_TEST(CopyNTest) {
int data[] = {1, 2, 3, 4, 8, 7, 6, 5};
const size_t vSize = 10;
TVector<int> result(10, 0);
@@ -575,7 +575,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(CopyIfTest) {
+ Y_UNIT_TEST(CopyIfTest) {
const size_t count = 9;
int data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
const size_t vSize = 10;
@@ -590,7 +590,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(MinMaxElementTest) {
+ Y_UNIT_TEST(MinMaxElementTest) {
TVector<int> v(10);
Iota(v.begin(), v.end(), 0);
UNIT_ASSERT_EQUAL(*MinMaxElement(v.begin(), v.end()).first, 0);
@@ -602,7 +602,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_EQUAL(*MinMaxElement(v.begin(), v.end()).second, 11);
}
- Y_UNIT_TEST(MinMaxTest) {
+ Y_UNIT_TEST(MinMaxTest) {
std::pair<int, int> p1 = MinMax(5, 12);
UNIT_ASSERT_EQUAL(p1.first, 5);
UNIT_ASSERT_EQUAL(p1.second, 12);
@@ -612,7 +612,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_EQUAL(p2.second, TString("test"));
}
- Y_UNIT_TEST(TestMaxElementBy) {
+ Y_UNIT_TEST(TestMaxElementBy) {
const int array[] = {1, 2, 5, 3, 4, 5};
UNIT_ASSERT_VALUES_EQUAL(*MaxElementBy(array, [](int x) {
return x * x;
@@ -638,7 +638,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_STRINGS_EQUAL(*MaxElementBy(strings, [](TString s) { return s.size(); }), "three");
}
- Y_UNIT_TEST(TestMinElementBy) {
+ Y_UNIT_TEST(TestMinElementBy) {
const int array[] = {2, 3, 4, 1, 5};
UNIT_ASSERT_VALUES_EQUAL(*MinElementBy(array, [](int x) -> char {
return 'a' + x;
@@ -668,12 +668,12 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_STRINGS_EQUAL(*MinElementBy(strings.rbegin(), strings.rend(), stringLength), "two");
}
- Y_UNIT_TEST(MaxElementByReturnsEndForEmptyRange) {
+ Y_UNIT_TEST(MaxElementByReturnsEndForEmptyRange) {
const TVector<int> empty;
UNIT_ASSERT_EQUAL(MaxElementBy(empty, [](int) { return 0; }), empty.end());
}
- Y_UNIT_TEST(MaxElementByDoesntCallFunctorForEmptyRange) {
+ Y_UNIT_TEST(MaxElementByDoesntCallFunctorForEmptyRange) {
const TVector<int> empty;
auto functor = [](int) {
UNIT_ASSERT(false);
@@ -682,12 +682,12 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
MaxElementBy(empty, functor);
}
- Y_UNIT_TEST(MinElementByReturnsEndForEmptyRange) {
+ Y_UNIT_TEST(MinElementByReturnsEndForEmptyRange) {
const TVector<int> empty;
UNIT_ASSERT_EQUAL(MinElementBy(empty, [](int) { return 0; }), empty.end());
}
- Y_UNIT_TEST(MinElementByDoesntCallFunctorForEmptyRange) {
+ Y_UNIT_TEST(MinElementByDoesntCallFunctorForEmptyRange) {
const TVector<int> empty;
auto functor = [](int) {
UNIT_ASSERT(false);
@@ -756,7 +756,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
}
- Y_UNIT_TEST(FindIfForContainer) {
+ Y_UNIT_TEST(FindIfForContainer) {
using std::begin;
using std::end;
@@ -790,14 +790,14 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
return &r + 1;
}
- Y_UNIT_TEST(FindIfForUserType) {
+ Y_UNIT_TEST(FindIfForUserType) {
// Compileability test. Should work for user types with begin/end overloads
TRange range;
auto i = FindIf(range, [](auto) { return false; });
Y_UNUSED(i);
}
- Y_UNIT_TEST(TestLowerBoundBy) {
+ Y_UNIT_TEST(TestLowerBoundBy) {
using TIntPairs = TVector<std::pair<i32, i32>>;
auto data = TIntPairs{{1, 5}, {3, 2}, {3, 4}, {8, 0}, {5, 4}};
@@ -817,7 +817,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT_EQUAL((it + 1)->second, 4);
}
- Y_UNIT_TEST(TestUpperBoundBy) {
+ Y_UNIT_TEST(TestUpperBoundBy) {
using TIntPairs = TVector<std::pair<i32, i32>>;
auto data = TIntPairs{{1, 5}, {3, 2}, {3, 4}, {8, 0}, {5, 4}};
@@ -836,7 +836,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
UNIT_ASSERT((it + 1) == data.end());
}
- Y_UNIT_TEST(TestFindInContainer) {
+ Y_UNIT_TEST(TestFindInContainer) {
std::vector<int> v = {1, 2, 1000, 15, 100};
UNIT_ASSERT(Find(v, 5) == v.end());
UNIT_ASSERT(Find(v, 1) == v.begin());
diff --git a/util/generic/array_ref.h b/util/generic/array_ref.h
index ae3eff8e19..1ac60ac7d3 100644
--- a/util/generic/array_ref.h
+++ b/util/generic/array_ref.h
@@ -259,16 +259,16 @@ constexpr TArrayRef<typename Range::value_type> MakeArrayRef(Range& range) {
return TArrayRef<typename Range::value_type>(range);
}
-template <class Range>
-constexpr TArrayRef<const typename Range::value_type> MakeConstArrayRef(const Range& range) {
- return TArrayRef<const typename Range::value_type>(range);
-}
-
-template <class Range>
-constexpr TArrayRef<const typename Range::value_type> MakeConstArrayRef(Range& range) {
- return TArrayRef<const typename Range::value_type>(range);
-}
-
+template <class Range>
+constexpr TArrayRef<const typename Range::value_type> MakeConstArrayRef(const Range& range) {
+ return TArrayRef<const typename Range::value_type>(range);
+}
+
+template <class Range>
+constexpr TArrayRef<const typename Range::value_type> MakeConstArrayRef(Range& range) {
+ return TArrayRef<const typename Range::value_type>(range);
+}
+
template <class T>
constexpr TArrayRef<T> MakeArrayRef(T* data, size_t size) {
return TArrayRef<T>(data, size);
diff --git a/util/generic/array_ref_ut.cpp b/util/generic/array_ref_ut.cpp
index 33ae908a71..4c8eaf7135 100644
--- a/util/generic/array_ref_ut.cpp
+++ b/util/generic/array_ref_ut.cpp
@@ -2,7 +2,7 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TestArrayRef) {
+Y_UNIT_TEST_SUITE(TestArrayRef) {
Y_UNIT_TEST(TestDefaultConstructor) {
TArrayRef<int> defaulted;
UNIT_ASSERT_VALUES_EQUAL(defaulted.data(), nullptr);
@@ -195,7 +195,7 @@ Y_UNIT_TEST_SUITE(TestArrayRef) {
UNIT_ASSERT_EQUAL(aRef.subspan(1, 3), MakeArrayRef(std::vector<int>{2, 3, 4}));
}
- Y_UNIT_TEST(TestSlice) {
+ Y_UNIT_TEST(TestSlice) {
const int a0[] = {1, 2, 3};
TArrayRef<const int> r0(a0);
TArrayRef<const int> s0 = r0.Slice(2);
@@ -278,7 +278,7 @@ Y_UNIT_TEST_SUITE(TestArrayRef) {
a[0] = 8;
}
- Y_UNIT_TEST(TestConst) {
+ Y_UNIT_TEST(TestConst) {
int a[] = {1, 2};
Do(a);
UNIT_ASSERT_VALUES_EQUAL(a[0], 8);
@@ -298,25 +298,25 @@ Y_UNIT_TEST_SUITE(TestArrayRef) {
static_assert(r2.size() == 4, "r2.size() is not equal to 4");
static_assert(r2.data()[2] == -3, "r2.data()[2] is not equal to -3");
}
-
- template <typename T>
- static void Foo(const TConstArrayRef<T>) {
- // noop
- }
-
- Y_UNIT_TEST(TestMakeConstArrayRef) {
- TVector<int> data;
-
- // Won't compile because can't deduce `T` for `Foo`
- // Foo(data);
-
- // Won't compile because again can't deduce `T` for `Foo`
- // Foo(MakeArrayRef(data));
-
- // Success!
- Foo(MakeConstArrayRef(data));
-
- const TVector<int> constData;
- Foo(MakeConstArrayRef(constData));
- }
+
+ template <typename T>
+ static void Foo(const TConstArrayRef<T>) {
+ // noop
+ }
+
+ Y_UNIT_TEST(TestMakeConstArrayRef) {
+ TVector<int> data;
+
+ // Won't compile because can't deduce `T` for `Foo`
+ // Foo(data);
+
+ // Won't compile because again can't deduce `T` for `Foo`
+ // Foo(MakeArrayRef(data));
+
+ // Success!
+ Foo(MakeConstArrayRef(data));
+
+ const TVector<int> constData;
+ Foo(MakeConstArrayRef(constData));
+ }
}
diff --git a/util/generic/array_size.h b/util/generic/array_size.h
index a56944b4ae..4d5f18ce63 100644
--- a/util/generic/array_size.h
+++ b/util/generic/array_size.h
@@ -21,4 +21,4 @@ namespace NArraySizePrivate {
};
}
-#define Y_ARRAY_SIZE(arr) ((size_t)::NArraySizePrivate::TArraySize<decltype(arr)>::Result)
+#define Y_ARRAY_SIZE(arr) ((size_t)::NArraySizePrivate::TArraySize<decltype(arr)>::Result)
diff --git a/util/generic/array_size_ut.cpp b/util/generic/array_size_ut.cpp
index b3243425a9..13f45903c5 100644
--- a/util/generic/array_size_ut.cpp
+++ b/util/generic/array_size_ut.cpp
@@ -2,21 +2,21 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(ArraySizeTest) {
- Y_UNIT_TEST(Test1) {
+Y_UNIT_TEST_SUITE(ArraySizeTest) {
+ Y_UNIT_TEST(Test1) {
int x[100];
- Y_UNUSED(x); /* Make MSVC happy. */
+ Y_UNUSED(x); /* Make MSVC happy. */
- UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(x), 100);
+ UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(x), 100);
}
- Y_UNIT_TEST(Test2) {
+ Y_UNIT_TEST(Test2) {
struct T {
};
T x[1];
- Y_UNUSED(x); /* Make MSVC happy. */
+ Y_UNUSED(x); /* Make MSVC happy. */
- UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(x), 1);
+ UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(x), 1);
}
}
diff --git a/util/generic/benchmark/fastclp2/main.cpp b/util/generic/benchmark/fastclp2/main.cpp
index 69bf1dc960..49277db077 100644
--- a/util/generic/benchmark/fastclp2/main.cpp
+++ b/util/generic/benchmark/fastclp2/main.cpp
@@ -1,50 +1,50 @@
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/generic/bitops.h>
-#include <util/generic/vector.h>
-#include <util/generic/xrange.h>
-#include <util/generic/singleton.h>
-
-#include <util/random/fast.h>
-
-namespace {
- template <typename T, size_t N>
- struct TExamplesHolder {
- TExamplesHolder()
+
+#include <util/generic/bitops.h>
+#include <util/generic/vector.h>
+#include <util/generic/xrange.h>
+#include <util/generic/singleton.h>
+
+#include <util/random/fast.h>
+
+namespace {
+ template <typename T, size_t N>
+ struct TExamplesHolder {
+ TExamplesHolder()
: Examples(N)
{
- TFastRng<ui64> prng{42u * sizeof(T) * N};
- for (auto& x : Examples) {
- x = prng();
- }
- }
-
+ TFastRng<ui64> prng{42u * sizeof(T) * N};
+ for (auto& x : Examples) {
+ x = prng();
+ }
+ }
+
TVector<T> Examples;
- };
-}
-
+ };
+}
+
#define DEFINE_BENCHMARK(type, count) \
- Y_CPU_BENCHMARK(FastClp2_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FastClp2(e)); \
- } \
- } \
- }
-
-DEFINE_BENCHMARK(ui8, 1)
-DEFINE_BENCHMARK(ui8, 10)
-DEFINE_BENCHMARK(ui8, 100)
-DEFINE_BENCHMARK(ui16, 1)
-DEFINE_BENCHMARK(ui16, 10)
-DEFINE_BENCHMARK(ui16, 100)
-DEFINE_BENCHMARK(ui32, 1)
-DEFINE_BENCHMARK(ui32, 10)
-DEFINE_BENCHMARK(ui32, 100)
-DEFINE_BENCHMARK(ui64, 1)
-DEFINE_BENCHMARK(ui64, 10)
-DEFINE_BENCHMARK(ui64, 100)
-
-#undef DEFINE_BENCHMARKS
+ Y_CPU_BENCHMARK(FastClp2_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(FastClp2(e)); \
+ } \
+ } \
+ }
+
+DEFINE_BENCHMARK(ui8, 1)
+DEFINE_BENCHMARK(ui8, 10)
+DEFINE_BENCHMARK(ui8, 100)
+DEFINE_BENCHMARK(ui16, 1)
+DEFINE_BENCHMARK(ui16, 10)
+DEFINE_BENCHMARK(ui16, 100)
+DEFINE_BENCHMARK(ui32, 1)
+DEFINE_BENCHMARK(ui32, 10)
+DEFINE_BENCHMARK(ui32, 100)
+DEFINE_BENCHMARK(ui64, 1)
+DEFINE_BENCHMARK(ui64, 10)
+DEFINE_BENCHMARK(ui64, 100)
+
+#undef DEFINE_BENCHMARKS
diff --git a/util/generic/benchmark/fastclp2/metrics/main.py b/util/generic/benchmark/fastclp2/metrics/main.py
index 4baa3fe256..5573c6a5d7 100644
--- a/util/generic/benchmark/fastclp2/metrics/main.py
+++ b/util/generic/benchmark/fastclp2/metrics/main.py
@@ -1,5 +1,5 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/fastclp2/fastclp2', threads=8))
diff --git a/util/generic/benchmark/fastclp2/metrics/ya.make b/util/generic/benchmark/fastclp2/metrics/ya.make
index 9411e3d5d5..b2d17ebad3 100644
--- a/util/generic/benchmark/fastclp2/metrics/ya.make
+++ b/util/generic/benchmark/fastclp2/metrics/ya.make
@@ -1,21 +1,21 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/generic/benchmark/fastclp2)
-
-END()
+
+END()
diff --git a/util/generic/benchmark/fastclp2/ya.make b/util/generic/benchmark/fastclp2/ya.make
index a475d0c67f..976977014f 100644
--- a/util/generic/benchmark/fastclp2/ya.make
+++ b/util/generic/benchmark/fastclp2/ya.make
@@ -1,13 +1,13 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
Y_BENCHMARK()
-
-SRCS(
- main.cpp
-)
-
-END()
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/generic/benchmark/log2/main.cpp b/util/generic/benchmark/log2/main.cpp
index a5490aba67..969f09a309 100644
--- a/util/generic/benchmark/log2/main.cpp
+++ b/util/generic/benchmark/log2/main.cpp
@@ -1,30 +1,30 @@
#include <library/cpp/testing/benchmark/bench.h>
-
+
#include <library/cpp/fast_log/fast_log.h>
-
-#include <util/generic/singleton.h>
-#include <util/generic/vector.h>
-#include <util/random/fast.h>
-#include <util/generic/xrange.h>
-
-#include <cmath>
-namespace {
- template <typename T, size_t N>
- struct TExamplesHolder {
+
+#include <util/generic/singleton.h>
+#include <util/generic/vector.h>
+#include <util/random/fast.h>
+#include <util/generic/xrange.h>
+
+#include <cmath>
+namespace {
+ template <typename T, size_t N>
+ struct TExamplesHolder {
TVector<T> Examples;
-
- TExamplesHolder()
+
+ TExamplesHolder()
: Examples(N)
{
- TFastRng<ui64> prng{N * 42};
- for (auto& x : Examples) {
- x = prng.GenRandReal4() + prng.Uniform(1932); // 1934 is just a random number
- }
- }
- };
-}
-
-#define DEFINE_BENCHMARK(type, count) \
+ TFastRng<ui64> prng{N * 42};
+ for (auto& x : Examples) {
+ x = prng.GenRandReal4() + prng.Uniform(1932); // 1934 is just a random number
+ }
+ }
+ };
+}
+
+#define DEFINE_BENCHMARK(type, count) \
Y_CPU_BENCHMARK(libm_log2f_##type##_##count, iface) { \
const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
for (const auto i : xrange(iface.Iterations())) { \
@@ -44,64 +44,64 @@ namespace {
} \
} \
} \
- Y_CPU_BENCHMARK(STL_Log2_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(std::log2(e)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(STL_Log_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(std::log(e)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(Fast_Log2_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FastLog2f(e)); \
- } \
- } \
- } \
- \
+ Y_CPU_BENCHMARK(STL_Log2_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(std::log2(e)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(STL_Log_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(std::log(e)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(Fast_Log2_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(FastLog2f(e)); \
+ } \
+ } \
+ } \
+ \
Y_CPU_BENCHMARK(FastLogf##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FastLogf(e)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(Faster_Log2_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(FastLogf(e)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(Faster_Log2_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
Y_DO_NOT_OPTIMIZE_AWAY(FasterLog2f(e)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(Faster_Log_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(Faster_Log_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
Y_DO_NOT_OPTIMIZE_AWAY(FasterLogf(e)); \
- } \
- } \
+ } \
+ } \
} \
\
Y_CPU_BENCHMARK(Fastest_Log2f_##type##_##count, iface) { \
@@ -122,19 +122,19 @@ namespace {
Y_DO_NOT_OPTIMIZE_AWAY(FastestLogf(e)); \
} \
} \
- }
-
-DEFINE_BENCHMARK(float, 1)
-DEFINE_BENCHMARK(float, 2)
-DEFINE_BENCHMARK(float, 4)
-DEFINE_BENCHMARK(float, 8)
-DEFINE_BENCHMARK(float, 16)
-DEFINE_BENCHMARK(float, 32)
-DEFINE_BENCHMARK(float, 64)
-DEFINE_BENCHMARK(float, 128)
-DEFINE_BENCHMARK(float, 256)
-DEFINE_BENCHMARK(float, 1024)
-DEFINE_BENCHMARK(float, 2048)
-DEFINE_BENCHMARK(float, 4096)
-
-#undef DEFINE_BENCHMARK
+ }
+
+DEFINE_BENCHMARK(float, 1)
+DEFINE_BENCHMARK(float, 2)
+DEFINE_BENCHMARK(float, 4)
+DEFINE_BENCHMARK(float, 8)
+DEFINE_BENCHMARK(float, 16)
+DEFINE_BENCHMARK(float, 32)
+DEFINE_BENCHMARK(float, 64)
+DEFINE_BENCHMARK(float, 128)
+DEFINE_BENCHMARK(float, 256)
+DEFINE_BENCHMARK(float, 1024)
+DEFINE_BENCHMARK(float, 2048)
+DEFINE_BENCHMARK(float, 4096)
+
+#undef DEFINE_BENCHMARK
diff --git a/util/generic/benchmark/log2/metrics/main.py b/util/generic/benchmark/log2/metrics/main.py
index 873f17664c..26f6b57812 100644
--- a/util/generic/benchmark/log2/metrics/main.py
+++ b/util/generic/benchmark/log2/metrics/main.py
@@ -1,5 +1,5 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/log2/log2', threads=8))
diff --git a/util/generic/benchmark/log2/metrics/ya.make b/util/generic/benchmark/log2/metrics/ya.make
index 5afd7de200..eb987e38d2 100644
--- a/util/generic/benchmark/log2/metrics/ya.make
+++ b/util/generic/benchmark/log2/metrics/ya.make
@@ -1,21 +1,21 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/generic/benchmark/log2)
-
-END()
+
+END()
diff --git a/util/generic/benchmark/log2/ya.make b/util/generic/benchmark/log2/ya.make
index eeef80523b..45d751909e 100644
--- a/util/generic/benchmark/log2/ya.make
+++ b/util/generic/benchmark/log2/ya.make
@@ -1,17 +1,17 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
Y_BENCHMARK()
-
-SRCS(
- main.cpp
-)
-
-PEERDIR(
+
+SRCS(
+ main.cpp
+)
+
+PEERDIR(
library/cpp/fast_log
-)
-
-END()
+)
+
+END()
diff --git a/util/generic/benchmark/rotate_bits/main.cpp b/util/generic/benchmark/rotate_bits/main.cpp
index 929d2c4ca9..057edbe864 100644
--- a/util/generic/benchmark/rotate_bits/main.cpp
+++ b/util/generic/benchmark/rotate_bits/main.cpp
@@ -1,66 +1,66 @@
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/generic/vector.h>
-#include <util/generic/xrange.h>
-#include <util/generic/singleton.h>
-
-#include <util/random/fast.h>
-
-namespace {
- template <typename T>
- struct TExample {
- T Value;
- ui8 Shift;
- };
-
- template <typename T, size_t N>
- struct TExamplesHolder {
- TExamplesHolder()
+
+#include <util/generic/vector.h>
+#include <util/generic/xrange.h>
+#include <util/generic/singleton.h>
+
+#include <util/random/fast.h>
+
+namespace {
+ template <typename T>
+ struct TExample {
+ T Value;
+ ui8 Shift;
+ };
+
+ template <typename T, size_t N>
+ struct TExamplesHolder {
+ TExamplesHolder()
: Examples(N)
{
- TFastRng<ui64> prng{42u * sizeof(T) * N};
- for (auto& e : Examples) {
- e.Value = prng();
- e.Shift = prng() % (8 * sizeof(T));
- }
- }
-
+ TFastRng<ui64> prng{42u * sizeof(T) * N};
+ for (auto& e : Examples) {
+ e.Value = prng();
+ e.Shift = prng() % (8 * sizeof(T));
+ }
+ }
+
TVector<TExample<T>> Examples;
- };
-}
-
-#define DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(type, count) \
- Y_CPU_BENCHMARK(LeftRotate_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(RotateBitsLeft(e.Value, e.Shift)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(RightRotate_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(RotateBitsRight(e.Value, e.Shift)); \
- } \
- } \
- }
-
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 1)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 10)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 100)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 1)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 10)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 100)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 1)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 10)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 100)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 1)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 10)
-DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 100)
-
-#undef DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES
+ };
+}
+
+#define DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(type, count) \
+ Y_CPU_BENCHMARK(LeftRotate_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(RotateBitsLeft(e.Value, e.Shift)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(RightRotate_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(RotateBitsRight(e.Value, e.Shift)); \
+ } \
+ } \
+ }
+
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 1)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 10)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui8, 100)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 1)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 10)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui16, 100)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 1)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 10)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui32, 100)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 1)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 10)
+DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES(ui64, 100)
+
+#undef DEFINE_BENCHMARKS_FOR_UNSIGNED_TYPES
diff --git a/util/generic/benchmark/rotate_bits/metrics/main.py b/util/generic/benchmark/rotate_bits/metrics/main.py
index d752885779..b30555775f 100644
--- a/util/generic/benchmark/rotate_bits/metrics/main.py
+++ b/util/generic/benchmark/rotate_bits/metrics/main.py
@@ -1,5 +1,5 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/rotate_bits/rotate_bits', threads=8))
diff --git a/util/generic/benchmark/rotate_bits/metrics/ya.make b/util/generic/benchmark/rotate_bits/metrics/ya.make
index 3bef9fae8a..ac27d2f845 100644
--- a/util/generic/benchmark/rotate_bits/metrics/ya.make
+++ b/util/generic/benchmark/rotate_bits/metrics/ya.make
@@ -1,21 +1,21 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/generic/benchmark/rotate_bits)
-
-END()
+
+END()
diff --git a/util/generic/benchmark/rotate_bits/ya.make b/util/generic/benchmark/rotate_bits/ya.make
index a475d0c67f..976977014f 100644
--- a/util/generic/benchmark/rotate_bits/ya.make
+++ b/util/generic/benchmark/rotate_bits/ya.make
@@ -1,13 +1,13 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
Y_BENCHMARK()
-
-SRCS(
- main.cpp
-)
-
-END()
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/generic/benchmark/vector_count_ctor/f.cpp b/util/generic/benchmark/vector_count_ctor/f.cpp
index e5d0a2ba25..b89e351ba7 100644
--- a/util/generic/benchmark/vector_count_ctor/f.cpp
+++ b/util/generic/benchmark/vector_count_ctor/f.cpp
@@ -1,25 +1,25 @@
-#include "f.h"
-
+#include "f.h"
+
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/generic/vector.h>
-#include <util/generic/ptr.h>
-
-void CreateYvector(const size_t size, const size_t count) {
- for (size_t i = 0; i < count; ++i) {
- NBench::Clobber();
+
+#include <util/generic/vector.h>
+#include <util/generic/ptr.h>
+
+void CreateYvector(const size_t size, const size_t count) {
+ for (size_t i = 0; i < count; ++i) {
+ NBench::Clobber();
TVector<ui8> v(size);
- NBench::Escape(v.data());
- NBench::Clobber();
- }
-}
-
-void CreateCarray(const size_t size, const size_t count) {
- for (size_t i = 0; i < count; ++i) {
- NBench::Clobber();
- TArrayHolder<ui8> v(new ui8[size]);
- memset(v.Get(), 0, size * sizeof(ui8));
- NBench::Escape(v.Get());
- NBench::Clobber();
- }
-}
+ NBench::Escape(v.data());
+ NBench::Clobber();
+ }
+}
+
+void CreateCarray(const size_t size, const size_t count) {
+ for (size_t i = 0; i < count; ++i) {
+ NBench::Clobber();
+ TArrayHolder<ui8> v(new ui8[size]);
+ memset(v.Get(), 0, size * sizeof(ui8));
+ NBench::Escape(v.Get());
+ NBench::Clobber();
+ }
+}
diff --git a/util/generic/benchmark/vector_count_ctor/f.h b/util/generic/benchmark/vector_count_ctor/f.h
index c0b9e48803..a568341a45 100644
--- a/util/generic/benchmark/vector_count_ctor/f.h
+++ b/util/generic/benchmark/vector_count_ctor/f.h
@@ -1,9 +1,9 @@
-#pragma once
-
-#include <cstddef>
-
-// functions are declared in a separate translation unit so that compiler won't be able to see the
-// value of `size` during compilation.
-
-void CreateYvector(const size_t size, const size_t count);
-void CreateCarray(const size_t size, const size_t count);
+#pragma once
+
+#include <cstddef>
+
+// functions are declared in a separate translation unit so that compiler won't be able to see the
+// value of `size` during compilation.
+
+void CreateYvector(const size_t size, const size_t count);
+void CreateCarray(const size_t size, const size_t count);
diff --git a/util/generic/benchmark/vector_count_ctor/main.cpp b/util/generic/benchmark/vector_count_ctor/main.cpp
index 715186b40a..6fb1fda9c9 100644
--- a/util/generic/benchmark/vector_count_ctor/main.cpp
+++ b/util/generic/benchmark/vector_count_ctor/main.cpp
@@ -1,30 +1,30 @@
-#include "f.h"
-
+#include "f.h"
+
#include <library/cpp/testing/benchmark/bench.h>
-
-#define DEFINE_BENCHMARK(N) \
- Y_CPU_BENCHMARK(Yvector_##N, iface) { \
- CreateYvector(N, iface.Iterations()); \
- } \
- Y_CPU_BENCHMARK(Carray_##N, iface) { \
- CreateCarray(N, iface.Iterations()); \
- }
-
-DEFINE_BENCHMARK(1)
-DEFINE_BENCHMARK(2)
-DEFINE_BENCHMARK(8)
-DEFINE_BENCHMARK(10)
-DEFINE_BENCHMARK(16)
-DEFINE_BENCHMARK(20)
-DEFINE_BENCHMARK(1000)
-DEFINE_BENCHMARK(1024)
-DEFINE_BENCHMARK(8192)
-DEFINE_BENCHMARK(10000)
-DEFINE_BENCHMARK(65536)
-DEFINE_BENCHMARK(100000)
-DEFINE_BENCHMARK(4194304)
-DEFINE_BENCHMARK(1000000)
-DEFINE_BENCHMARK(33554432)
-DEFINE_BENCHMARK(10000000)
-DEFINE_BENCHMARK(268435456)
-DEFINE_BENCHMARK(100000000)
+
+#define DEFINE_BENCHMARK(N) \
+ Y_CPU_BENCHMARK(Yvector_##N, iface) { \
+ CreateYvector(N, iface.Iterations()); \
+ } \
+ Y_CPU_BENCHMARK(Carray_##N, iface) { \
+ CreateCarray(N, iface.Iterations()); \
+ }
+
+DEFINE_BENCHMARK(1)
+DEFINE_BENCHMARK(2)
+DEFINE_BENCHMARK(8)
+DEFINE_BENCHMARK(10)
+DEFINE_BENCHMARK(16)
+DEFINE_BENCHMARK(20)
+DEFINE_BENCHMARK(1000)
+DEFINE_BENCHMARK(1024)
+DEFINE_BENCHMARK(8192)
+DEFINE_BENCHMARK(10000)
+DEFINE_BENCHMARK(65536)
+DEFINE_BENCHMARK(100000)
+DEFINE_BENCHMARK(4194304)
+DEFINE_BENCHMARK(1000000)
+DEFINE_BENCHMARK(33554432)
+DEFINE_BENCHMARK(10000000)
+DEFINE_BENCHMARK(268435456)
+DEFINE_BENCHMARK(100000000)
diff --git a/util/generic/benchmark/vector_count_ctor/metrics/main.py b/util/generic/benchmark/vector_count_ctor/metrics/main.py
index f2602ed3ff..835b44fe5f 100644
--- a/util/generic/benchmark/vector_count_ctor/metrics/main.py
+++ b/util/generic/benchmark/vector_count_ctor/metrics/main.py
@@ -1,5 +1,5 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
metrics.set_benchmark(yc.execute_benchmark('util/generic/benchmark/vector_count_ctor/vector_count_ctor', threads=8))
diff --git a/util/generic/benchmark/vector_count_ctor/metrics/ya.make b/util/generic/benchmark/vector_count_ctor/metrics/ya.make
index 1441bcbf3a..c48f89b564 100644
--- a/util/generic/benchmark/vector_count_ctor/metrics/ya.make
+++ b/util/generic/benchmark/vector_count_ctor/metrics/ya.make
@@ -1,21 +1,21 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/generic/benchmark/vector_count_ctor)
-
-END()
+
+END()
diff --git a/util/generic/benchmark/vector_count_ctor/ya.make b/util/generic/benchmark/vector_count_ctor/ya.make
index 735d8cf397..42ce442819 100644
--- a/util/generic/benchmark/vector_count_ctor/ya.make
+++ b/util/generic/benchmark/vector_count_ctor/ya.make
@@ -1,16 +1,16 @@
-OWNER(
- yazevnul
- g:util
-)
+OWNER(
+ yazevnul
+ g:util
+)
SUBSCRIBER(g:util-subscribers)
-
+
Y_BENCHMARK()
-
-ALLOCATOR(B)
-
-SRCS(
- main.cpp
- f.cpp
-)
-
-END()
+
+ALLOCATOR(B)
+
+SRCS(
+ main.cpp
+ f.cpp
+)
+
+END()
diff --git a/util/generic/benchmark/ya.make b/util/generic/benchmark/ya.make
index 9c18713826..635860a646 100644
--- a/util/generic/benchmark/ya.make
+++ b/util/generic/benchmark/ya.make
@@ -1,19 +1,19 @@
OWNER(yazevnul g:util)
SUBSCRIBER(g:util-subscribers)
-
-RECURSE(
- fastclp2
- fastclp2/metrics
- log2
- log2/metrics
- rotate_bits
- rotate_bits/metrics
- singleton
+
+RECURSE(
+ fastclp2
+ fastclp2/metrics
+ log2
+ log2/metrics
+ rotate_bits
+ rotate_bits/metrics
+ singleton
smart_pointers
sort
string
- vector_count_ctor
+ vector_count_ctor
vector_count_ctor/metrics
cont_speed
-)
+)
diff --git a/util/generic/bitmap.h b/util/generic/bitmap.h
index dde9873936..f77d182460 100644
--- a/util/generic/bitmap.h
+++ b/util/generic/bitmap.h
@@ -31,12 +31,12 @@ namespace NBitMapPrivate {
template <typename TChunkType, size_t ExtraBits>
struct TSanitizeMask {
- static constexpr TChunkType Value = ~((~TChunkType(0)) << ExtraBits);
+ static constexpr TChunkType Value = ~((~TChunkType(0)) << ExtraBits);
};
template <typename TChunkType>
struct TSanitizeMask<TChunkType, 0> {
- static constexpr TChunkType Value = (TChunkType)~TChunkType(0u);
+ static constexpr TChunkType Value = (TChunkType)~TChunkType(0u);
};
template <typename TTargetChunk, typename TSourceChunk>
@@ -44,7 +44,7 @@ namespace NBitMapPrivate {
static_assert(sizeof(TTargetChunk) < sizeof(TSourceChunk), "expect sizeof(TTargetChunk) < sizeof(TSourceChunk)");
static_assert(0 == sizeof(TSourceChunk) % sizeof(TTargetChunk), "expect 0 == sizeof(TSourceChunk) % sizeof(TTargetChunk)");
- static constexpr size_t BLOCK_SIZE = sizeof(TSourceChunk) / sizeof(TTargetChunk);
+ static constexpr size_t BLOCK_SIZE = sizeof(TSourceChunk) / sizeof(TTargetChunk);
union TCnv {
TSourceChunk BigData;
@@ -55,14 +55,14 @@ namespace NBitMapPrivate {
TCnv c;
c.BigData = source;
#if defined(_big_endian_)
- ::ReverseCopy(c.SmallData, c.SmallData + Y_ARRAY_SIZE(c.SmallData), target);
+ ::ReverseCopy(c.SmallData, c.SmallData + Y_ARRAY_SIZE(c.SmallData), target);
#else
- ::Copy(c.SmallData, c.SmallData + Y_ARRAY_SIZE(c.SmallData), target);
+ ::Copy(c.SmallData, c.SmallData + Y_ARRAY_SIZE(c.SmallData), target);
#endif
}
static inline void Copy(TTargetChunk* target, size_t targetSize, const TSourceChunk* source, size_t sourceSize) {
- Y_ASSERT(targetSize >= sourceSize * BLOCK_SIZE);
+ Y_ASSERT(targetSize >= sourceSize * BLOCK_SIZE);
if (targetSize > sourceSize * BLOCK_SIZE) {
::Fill(target + sourceSize * BLOCK_SIZE, target + targetSize, 0);
}
@@ -77,7 +77,7 @@ namespace NBitMapPrivate {
static_assert(sizeof(TTargetChunk) > sizeof(TSourceChunk), "expect sizeof(TTargetChunk) > sizeof(TSourceChunk)");
static_assert(0 == sizeof(TTargetChunk) % sizeof(TSourceChunk), "expect 0 == sizeof(TTargetChunk) % sizeof(TSourceChunk)");
- static constexpr size_t BLOCK_SIZE = sizeof(TTargetChunk) / sizeof(TSourceChunk);
+ static constexpr size_t BLOCK_SIZE = sizeof(TTargetChunk) / sizeof(TSourceChunk);
union TCnv {
TSourceChunk SmallData[BLOCK_SIZE];
@@ -95,7 +95,7 @@ namespace NBitMapPrivate {
}
static inline TTargetChunk CopyPartChunk(const TSourceChunk* source, size_t count) {
- Y_ASSERT(count <= BLOCK_SIZE);
+ Y_ASSERT(count <= BLOCK_SIZE);
TCnv c;
c.BigData = 0;
#if defined(_big_endian_)
@@ -107,7 +107,7 @@ namespace NBitMapPrivate {
}
static inline void Copy(TTargetChunk* target, size_t targetSize, const TSourceChunk* source, size_t sourceSize) {
- Y_ASSERT(targetSize * BLOCK_SIZE >= sourceSize);
+ Y_ASSERT(targetSize * BLOCK_SIZE >= sourceSize);
if (targetSize * BLOCK_SIZE > sourceSize) {
::Fill(target + sourceSize / BLOCK_SIZE, target + targetSize, 0);
}
@@ -124,7 +124,7 @@ namespace NBitMapPrivate {
template <typename TChunk>
struct TUniformDataCopier {
static inline void Copy(TChunk* target, size_t targetSize, const TChunk* source, size_t sourceSize) {
- Y_ASSERT(targetSize >= sourceSize);
+ Y_ASSERT(targetSize >= sourceSize);
for (size_t i = 0; i < sourceSize; ++i) {
target[i] = source[i];
}
@@ -142,7 +142,7 @@ namespace NBitMapPrivate {
};
template <typename TTargetChunk, typename TSourceChunk>
- struct TDataCopier: public std::conditional_t<std::is_same<TTargetChunk, TSourceChunk>::value, TUniformDataCopier<TTargetChunk>, std::conditional_t<TIsSmaller<TTargetChunk, TSourceChunk>::Result, TBigToSmallDataCopier<TTargetChunk, TSourceChunk>, TSmallToBigDataCopier<TTargetChunk, TSourceChunk>>> {
+ struct TDataCopier: public std::conditional_t<std::is_same<TTargetChunk, TSourceChunk>::value, TUniformDataCopier<TTargetChunk>, std::conditional_t<TIsSmaller<TTargetChunk, TSourceChunk>::Result, TBigToSmallDataCopier<TTargetChunk, TSourceChunk>, TSmallToBigDataCopier<TTargetChunk, TSourceChunk>>> {
};
template <typename TTargetChunk, typename TSourceChunk>
@@ -154,7 +154,7 @@ namespace NBitMapPrivate {
struct TFixedStorage {
using TChunk = TChunkType;
- static constexpr size_t Size = (BitCount + 8 * sizeof(TChunk) - 1) / (8 * sizeof(TChunk));
+ static constexpr size_t Size = (BitCount + 8 * sizeof(TChunk) - 1) / (8 * sizeof(TChunk));
TChunk Data[Size];
@@ -170,7 +170,7 @@ namespace NBitMapPrivate {
template <typename TOtherChunk>
TFixedStorage(const TOtherChunk* data, size_t size) {
- Y_VERIFY(Size * sizeof(TChunk) >= size * sizeof(TOtherChunk), "Exceeding bitmap storage capacity");
+ Y_VERIFY(Size * sizeof(TChunk) >= size * sizeof(TOtherChunk), "Exceeding bitmap storage capacity");
CopyData(Data, Size, data, size);
}
@@ -180,16 +180,16 @@ namespace NBitMapPrivate {
}
}
- Y_FORCE_INLINE static constexpr size_t GetBitCapacity() noexcept {
+ Y_FORCE_INLINE static constexpr size_t GetBitCapacity() noexcept {
return BitCount;
}
- Y_FORCE_INLINE static constexpr size_t GetChunkCapacity() noexcept {
+ Y_FORCE_INLINE static constexpr size_t GetChunkCapacity() noexcept {
return Size;
}
// Returns true if the resulting storage capacity is enough to fit the requested size
- Y_FORCE_INLINE static constexpr bool ExpandBitSize(const size_t bitSize) noexcept {
+ Y_FORCE_INLINE static constexpr bool ExpandBitSize(const size_t bitSize) noexcept {
return bitSize <= BitCount;
}
@@ -286,12 +286,12 @@ namespace NBitMapPrivate {
template <size_t num>
struct TDivCount {
- static constexpr size_t Value = 1 + TDivCount<(num >> 1)>::Value;
+ static constexpr size_t Value = 1 + TDivCount<(num >> 1)>::Value;
};
template <>
struct TDivCount<0> {
- static constexpr size_t Value = 0;
+ static constexpr size_t Value = 0;
};
}
@@ -317,10 +317,10 @@ public:
private:
static_assert(std::is_unsigned<TChunk>::value, "expect std::is_unsigned<TChunk>::value");
- static constexpr size_t BitsPerChunk = 8 * sizeof(TChunk);
- static constexpr TChunk ModMask = static_cast<TChunk>(BitsPerChunk - 1);
- static constexpr size_t DivCount = NBitMapPrivate::TDivCount<BitsPerChunk>::Value - 1;
- static constexpr TChunk FullChunk = (TChunk)~TChunk(0);
+ static constexpr size_t BitsPerChunk = 8 * sizeof(TChunk);
+ static constexpr TChunk ModMask = static_cast<TChunk>(BitsPerChunk - 1);
+ static constexpr size_t DivCount = NBitMapPrivate::TDivCount<BitsPerChunk>::Value - 1;
+ static constexpr TChunk FullChunk = (TChunk)~TChunk(0);
template <class>
friend class TBitMapOps;
@@ -328,7 +328,7 @@ private:
using TStorage = typename TTraits::TStorage;
// The smallest unsigned type, which can be used in bit ops
- using TIntType = std::conditional_t<sizeof(TChunk) < sizeof(unsigned int), unsigned int, TChunk>;
+ using TIntType = std::conditional_t<sizeof(TChunk) < sizeof(unsigned int), unsigned int, TChunk>;
TStorage Mask;
@@ -383,13 +383,13 @@ public:
private:
struct TSetOp {
- static constexpr TChunk Op(const TChunk src, const TChunk mask) noexcept {
+ static constexpr TChunk Op(const TChunk src, const TChunk mask) noexcept {
return src | mask;
}
};
struct TResetOp {
- static constexpr TChunk Op(const TChunk src, const TChunk mask) noexcept {
+ static constexpr TChunk Op(const TChunk src, const TChunk mask) noexcept {
return src & ~mask;
}
};
@@ -510,7 +510,7 @@ public:
Y_FORCE_INLINE TReference operator[](size_t pos) {
const bool fitStorage = Mask.ExpandBitSize(pos + 1);
- Y_ASSERT(fitStorage);
+ Y_ASSERT(fitStorage);
return TReference(&Mask.Data[pos >> DivCount], ModMask & pos);
}
@@ -520,14 +520,14 @@ public:
Y_FORCE_INLINE TThis& Set(size_t pos) {
const bool fitStorage = Mask.ExpandBitSize(pos + 1);
- Y_ASSERT(fitStorage);
+ Y_ASSERT(fitStorage);
Mask.Data[pos >> DivCount] |= static_cast<TChunk>(1) << (pos & ModMask);
return *this;
}
// Fills the specified [start, end) bit range by the 1. Other bits are kept unchanged
TThis& Set(size_t start, size_t end) {
- Y_ASSERT(start <= end);
+ Y_ASSERT(start <= end);
if (start < end) {
Reserve(end);
UpdateRange<TSetOp>(start, end);
@@ -544,7 +544,7 @@ public:
// Clears the specified [start, end) bit range. Other bits are kept unchanged
TThis& Reset(size_t start, size_t end) {
- Y_ASSERT(start <= end);
+ Y_ASSERT(start <= end);
if (start < end && (start >> DivCount) < Mask.GetChunkCapacity()) {
UpdateRange<TResetOp>(start, Min(end, Mask.GetBitCapacity()));
}
@@ -553,7 +553,7 @@ public:
Y_FORCE_INLINE TThis& Flip(size_t pos) {
const bool fitStorage = Mask.ExpandBitSize(pos + 1);
- Y_ASSERT(fitStorage);
+ Y_ASSERT(fitStorage);
Mask.Data[pos >> DivCount] ^= static_cast<TChunk>(1) << (pos & ModMask);
return *this;
}
@@ -580,7 +580,7 @@ public:
} else if ((pos & (sizeof(TTo) * 8 - 1)) == 0 && sizeof(TChunk) >= 2 * sizeof(TTo))
to = (TTo)(Mask.Data[chunkpos] >> (pos & ModMask));
else {
- static constexpr size_t copyToSize = (sizeof(TChunk) >= sizeof(TTo)) ? (sizeof(TChunk) / sizeof(TTo)) + 2 : 3;
+ static constexpr size_t copyToSize = (sizeof(TChunk) >= sizeof(TTo)) ? (sizeof(TChunk) / sizeof(TTo)) + 2 : 3;
TTo temp[copyToSize] = {0, 0};
//or use non defined by now TBitmap<copyToSize, TTo>::CopyData,RShift(pos & ModMask),Export(0,to)
NBitMapPrivate::CopyData(temp, copyToSize, Mask.Data + chunkpos, Min((sizeof(TTo) / sizeof(TChunk)) + 1, Mask.GetChunkCapacity() - chunkpos));
@@ -611,12 +611,12 @@ public:
}
// Returns bits capacity
- Y_FORCE_INLINE constexpr size_t Size() const noexcept {
+ Y_FORCE_INLINE constexpr size_t Size() const noexcept {
return Mask.GetBitCapacity();
}
Y_FORCE_INLINE void Reserve(size_t bitCount) {
- Y_VERIFY(Mask.ExpandBitSize(bitCount), "Exceeding bitmap storage capacity");
+ Y_VERIFY(Mask.ExpandBitSize(bitCount), "Exceeding bitmap storage capacity");
}
Y_FORCE_INLINE size_t ValueBitCount() const {
@@ -624,7 +624,7 @@ public:
while (nonZeroChunk != 0 && !Mask.Data[nonZeroChunk])
--nonZeroChunk;
return nonZeroChunk || Mask.Data[nonZeroChunk]
- ? nonZeroChunk * BitsPerChunk + GetValueBitCount(TIntType(Mask.Data[nonZeroChunk]))
+ ? nonZeroChunk * BitsPerChunk + GetValueBitCount(TIntType(Mask.Data[nonZeroChunk]))
: 0;
}
@@ -926,7 +926,7 @@ public:
// for (size_t pos = bits.FirstNonZeroBit(); pos != bits.Size(); pos = bits.NextNonZeroBit(pos)) {
// ...
// }
- // See Y_FOR_EACH_BIT macro definition at the bottom
+ // See Y_FOR_EACH_BIT macro definition at the bottom
size_t NextNonZeroBit(size_t pos) const {
size_t i = (pos + 1) >> DivCount;
if (i < Mask.GetChunkCapacity()) {
@@ -958,16 +958,16 @@ public:
return count;
}
- void Save(IOutputStream* out) const {
+ void Save(IOutputStream* out) const {
::Save(out, ui8(sizeof(TChunk)));
::Save(out, ui64(Size()));
::SavePodArray(out, Mask.Data, Mask.GetChunkCapacity());
}
- void Load(IInputStream* inp) {
+ void Load(IInputStream* inp) {
ui8 chunkSize = 0;
::Load(inp, chunkSize);
- Y_VERIFY(size_t(chunkSize) == sizeof(TChunk), "Chunk size is not the same");
+ Y_VERIFY(size_t(chunkSize) == sizeof(TChunk), "Chunk size is not the same");
ui64 bitCount64 = 0;
::Load(inp, bitCount64);
@@ -1005,7 +1005,7 @@ public:
return Mask.Data;
}
- constexpr size_t GetChunkCount() const noexcept {
+ constexpr size_t GetChunkCount() const noexcept {
return Mask.GetChunkCapacity();
}
};
@@ -1104,7 +1104,7 @@ public:
using TDynBitMap = TBitMapOps<TDynamicBitMapTraits<ui64>>;
-#define Y_FOR_EACH_BIT(var, bitmap) for (size_t var = (bitmap).FirstNonZeroBit(); var != (bitmap).Size(); var = (bitmap).NextNonZeroBit(var))
+#define Y_FOR_EACH_BIT(var, bitmap) for (size_t var = (bitmap).FirstNonZeroBit(); var != (bitmap).Size(); var = (bitmap).NextNonZeroBit(var))
template <typename TTraits>
struct THash<TBitMapOps<TTraits>> {
diff --git a/util/generic/bitmap_ut.cpp b/util/generic/bitmap_ut.cpp
index 47032bfe53..087d34a8dc 100644
--- a/util/generic/bitmap_ut.cpp
+++ b/util/generic/bitmap_ut.cpp
@@ -37,8 +37,8 @@
} \
}
-Y_UNIT_TEST_SUITE(TBitMapTest) {
- Y_UNIT_TEST(TestBitMap) {
+Y_UNIT_TEST_SUITE(TBitMapTest) {
+ Y_UNIT_TEST(TestBitMap) {
TBitMap<101> bitmap;
UNIT_ASSERT_EQUAL(bitmap.Size(), 101);
@@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(bitmap.Empty(), true);
}
- Y_UNIT_TEST(TestDynBitMap) {
+ Y_UNIT_TEST(TestDynBitMap) {
TDynBitMap bitmap;
UNIT_ASSERT_EQUAL(bitmap.Size(), 64); // Initial capacity
@@ -124,11 +124,11 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
CHECK_BITMAP(bitmap2, initBits2);
}
- Y_UNIT_TEST(TestAndFixed) {
+ Y_UNIT_TEST(TestAndFixed) {
TestAndImpl<TBitMap<101>>();
}
- Y_UNIT_TEST(TestAndDyn) {
+ Y_UNIT_TEST(TestAndDyn) {
TestAndImpl<TDynBitMap>();
}
@@ -165,15 +165,15 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(bitmap2 | (bitmap1 << 66), TBitMapImpl(bitmap2).Or(bitmap1, 66));
}
- Y_UNIT_TEST(TestOrFixed) {
+ Y_UNIT_TEST(TestOrFixed) {
TestOrImpl<TBitMap<145>>();
}
- Y_UNIT_TEST(TestOrDyn) {
+ Y_UNIT_TEST(TestOrDyn) {
TestOrImpl<TDynBitMap>();
}
- Y_UNIT_TEST(TestCopy) {
+ Y_UNIT_TEST(TestCopy) {
TBitMap<101> bitmap1;
size_t initBits[] = {0, 10, 11, 76, 100};
@@ -239,7 +239,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
CHECK_BITMAP(bitmap16, initBits);
}
- Y_UNIT_TEST(TestOps) {
+ Y_UNIT_TEST(TestOps) {
TBitMap<16> bitmap1;
TBitMap<12> bitmap2;
size_t initBits1[] = {0, 3, 7, 11};
@@ -286,7 +286,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(tst3, (1 << 14));
}
- Y_UNIT_TEST(TestShiftFixed) {
+ Y_UNIT_TEST(TestShiftFixed) {
size_t initBits[] = {0, 3, 7, 11};
TBitMap<128> bitmap1;
@@ -330,7 +330,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(bitmap1.Empty(), true);
}
- Y_UNIT_TEST(TestShiftDyn) {
+ Y_UNIT_TEST(TestShiftDyn) {
size_t initBits[] = {0, 3, 7, 11};
TDynBitMap bitmap1;
@@ -371,7 +371,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
}
// Test that we don't expand bitmap in LShift when high-order bits are zero
- Y_UNIT_TEST(TestShiftExpansion) {
+ Y_UNIT_TEST(TestShiftExpansion) {
UNIT_ASSERT_EQUAL(TDynBitMap().LShift(1).Size(), 64);
UNIT_ASSERT_EQUAL(TDynBitMap().LShift(65).Size(), 64);
UNIT_ASSERT_EQUAL(TDynBitMap().LShift(128).Size(), 64);
@@ -402,7 +402,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(bitmap.Size(), 256);
}
- Y_UNIT_TEST(TestFixedSanity) {
+ Y_UNIT_TEST(TestFixedSanity) {
// test extra-bit cleanup
UNIT_ASSERT_EQUAL(TBitMap<33>().Set(0).LShift(34).RShift(34).Empty(), true);
UNIT_ASSERT_EQUAL(TBitMap<88>().Set(0).Set(1).Set(2).LShift(90).RShift(90).Empty(), true);
@@ -416,7 +416,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(TBitMap<33>().Xor(TBitMap<40>().Set(39)).Empty(), true);
}
- Y_UNIT_TEST(TestIterate) {
+ Y_UNIT_TEST(TestIterate) {
TDynBitMap bitmap1;
TDynBitMap bitmap2;
@@ -475,7 +475,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(bitmap4.NextNonZeroBit(533), bitmap4.Size());
}
- Y_UNIT_TEST(TestHashFixed) {
+ Y_UNIT_TEST(TestHashFixed) {
TBitMap<32, ui8> bitmap32;
TBitMap<32, ui8> bitmap322;
TBitMap<64, ui8> bitmap64;
@@ -507,7 +507,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_UNEQUAL(bitmap32.Hash(), bitmap64.Hash());
}
- Y_UNIT_TEST(TestHashDynamic) {
+ Y_UNIT_TEST(TestHashDynamic) {
TDynBitMap bitmap1;
TDynBitMap bitmap2;
@@ -528,7 +528,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(bitmap1.Hash(), bitmap2.Hash());
}
- Y_UNIT_TEST(TestHashMixed) {
+ Y_UNIT_TEST(TestHashMixed) {
static_assert((std::is_same<TDynBitMap::TChunk, ui64>::value), "expect (TSameType<TDynBitMap::TChunk, ui64>::Result)");
TBitMap<sizeof(ui64) * 16, ui64> bitmapFixed;
@@ -549,7 +549,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_UNEQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash());
}
- Y_UNIT_TEST(TestSetResetRange) {
+ Y_UNIT_TEST(TestSetResetRange) {
// Single chunk
using TBitMap1Chunk = TBitMap<64>;
UNIT_ASSERT_EQUAL(TBitMap1Chunk().Flip().Reset(10, 50), TBitMap1Chunk().Set(0, 10).Set(50, 64));
@@ -572,7 +572,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
UNIT_ASSERT_EQUAL(TBitMap4Chunks().Flip().Reset(0, 10).Reset(50, 64), TBitMap4Chunks().Set(10, 50));
}
- Y_UNIT_TEST(TestSetRangeDyn) {
+ Y_UNIT_TEST(TestSetRangeDyn) {
for (size_t start = 0; start < 192; ++start) {
for (size_t end = start; end < 192; ++end) {
TDynBitMap bm;
diff --git a/util/generic/bitops.cpp b/util/generic/bitops.cpp
index cee2667f4b..db5667a21f 100644
--- a/util/generic/bitops.cpp
+++ b/util/generic/bitops.cpp
@@ -1,141 +1,141 @@
#include "bitops.h"
-
-namespace NBitOps {
- namespace NPrivate {
- const ui64 WORD_MASK[] = {
- 0x0000000000000000ULL,
- 0x0000000000000001ULL,
- 0x0000000000000003ULL,
- 0x0000000000000007ULL,
- 0x000000000000000FULL,
- 0x000000000000001FULL,
- 0x000000000000003FULL,
- 0x000000000000007FULL,
- 0x00000000000000FFULL,
- 0x00000000000001FFULL,
- 0x00000000000003FFULL,
- 0x00000000000007FFULL,
- 0x0000000000000FFFULL,
- 0x0000000000001FFFULL,
- 0x0000000000003FFFULL,
- 0x0000000000007FFFULL,
- 0x000000000000FFFFULL,
- 0x000000000001FFFFULL,
- 0x000000000003FFFFULL,
- 0x000000000007FFFFULL,
- 0x00000000000FFFFFULL,
- 0x00000000001FFFFFULL,
- 0x00000000003FFFFFULL,
- 0x00000000007FFFFFULL,
- 0x0000000000FFFFFFULL,
- 0x0000000001FFFFFFULL,
- 0x0000000003FFFFFFULL,
- 0x0000000007FFFFFFULL,
- 0x000000000FFFFFFFULL,
- 0x000000001FFFFFFFULL,
- 0x000000003FFFFFFFULL,
- 0x000000007FFFFFFFULL,
- 0x00000000FFFFFFFFULL,
- 0x00000001FFFFFFFFULL,
- 0x00000003FFFFFFFFULL,
- 0x00000007FFFFFFFFULL,
- 0x0000000FFFFFFFFFULL,
- 0x0000001FFFFFFFFFULL,
- 0x0000003FFFFFFFFFULL,
- 0x0000007FFFFFFFFFULL,
- 0x000000FFFFFFFFFFULL,
- 0x000001FFFFFFFFFFULL,
- 0x000003FFFFFFFFFFULL,
- 0x000007FFFFFFFFFFULL,
- 0x00000FFFFFFFFFFFULL,
- 0x00001FFFFFFFFFFFULL,
- 0x00003FFFFFFFFFFFULL,
- 0x00007FFFFFFFFFFFULL,
- 0x0000FFFFFFFFFFFFULL,
- 0x0001FFFFFFFFFFFFULL,
- 0x0003FFFFFFFFFFFFULL,
- 0x0007FFFFFFFFFFFFULL,
- 0x000FFFFFFFFFFFFFULL,
- 0x001FFFFFFFFFFFFFULL,
- 0x003FFFFFFFFFFFFFULL,
- 0x007FFFFFFFFFFFFFULL,
- 0x00FFFFFFFFFFFFFFULL,
- 0x01FFFFFFFFFFFFFFULL,
- 0x03FFFFFFFFFFFFFFULL,
- 0x07FFFFFFFFFFFFFFULL,
- 0x0FFFFFFFFFFFFFFFULL,
- 0x1FFFFFFFFFFFFFFFULL,
- 0x3FFFFFFFFFFFFFFFULL,
- 0x7FFFFFFFFFFFFFFFULL,
- 0xFFFFFFFFFFFFFFFFULL,
- };
-
- const ui64 INVERSE_WORD_MASK[] = {
- ~0x0000000000000000ULL,
- ~0x0000000000000001ULL,
- ~0x0000000000000003ULL,
- ~0x0000000000000007ULL,
- ~0x000000000000000FULL,
- ~0x000000000000001FULL,
- ~0x000000000000003FULL,
- ~0x000000000000007FULL,
- ~0x00000000000000FFULL,
- ~0x00000000000001FFULL,
- ~0x00000000000003FFULL,
- ~0x00000000000007FFULL,
- ~0x0000000000000FFFULL,
- ~0x0000000000001FFFULL,
- ~0x0000000000003FFFULL,
- ~0x0000000000007FFFULL,
- ~0x000000000000FFFFULL,
- ~0x000000000001FFFFULL,
- ~0x000000000003FFFFULL,
- ~0x000000000007FFFFULL,
- ~0x00000000000FFFFFULL,
- ~0x00000000001FFFFFULL,
- ~0x00000000003FFFFFULL,
- ~0x00000000007FFFFFULL,
- ~0x0000000000FFFFFFULL,
- ~0x0000000001FFFFFFULL,
- ~0x0000000003FFFFFFULL,
- ~0x0000000007FFFFFFULL,
- ~0x000000000FFFFFFFULL,
- ~0x000000001FFFFFFFULL,
- ~0x000000003FFFFFFFULL,
- ~0x000000007FFFFFFFULL,
- ~0x00000000FFFFFFFFULL,
- ~0x00000001FFFFFFFFULL,
- ~0x00000003FFFFFFFFULL,
- ~0x00000007FFFFFFFFULL,
- ~0x0000000FFFFFFFFFULL,
- ~0x0000001FFFFFFFFFULL,
- ~0x0000003FFFFFFFFFULL,
- ~0x0000007FFFFFFFFFULL,
- ~0x000000FFFFFFFFFFULL,
- ~0x000001FFFFFFFFFFULL,
- ~0x000003FFFFFFFFFFULL,
- ~0x000007FFFFFFFFFFULL,
- ~0x00000FFFFFFFFFFFULL,
- ~0x00001FFFFFFFFFFFULL,
- ~0x00003FFFFFFFFFFFULL,
- ~0x00007FFFFFFFFFFFULL,
- ~0x0000FFFFFFFFFFFFULL,
- ~0x0001FFFFFFFFFFFFULL,
- ~0x0003FFFFFFFFFFFFULL,
- ~0x0007FFFFFFFFFFFFULL,
- ~0x000FFFFFFFFFFFFFULL,
- ~0x001FFFFFFFFFFFFFULL,
- ~0x003FFFFFFFFFFFFFULL,
- ~0x007FFFFFFFFFFFFFULL,
- ~0x00FFFFFFFFFFFFFFULL,
- ~0x01FFFFFFFFFFFFFFULL,
- ~0x03FFFFFFFFFFFFFFULL,
- ~0x07FFFFFFFFFFFFFFULL,
- ~0x0FFFFFFFFFFFFFFFULL,
- ~0x1FFFFFFFFFFFFFFFULL,
- ~0x3FFFFFFFFFFFFFFFULL,
- ~0x7FFFFFFFFFFFFFFFULL,
- ~0xFFFFFFFFFFFFFFFFULL,
- };
+
+namespace NBitOps {
+ namespace NPrivate {
+ const ui64 WORD_MASK[] = {
+ 0x0000000000000000ULL,
+ 0x0000000000000001ULL,
+ 0x0000000000000003ULL,
+ 0x0000000000000007ULL,
+ 0x000000000000000FULL,
+ 0x000000000000001FULL,
+ 0x000000000000003FULL,
+ 0x000000000000007FULL,
+ 0x00000000000000FFULL,
+ 0x00000000000001FFULL,
+ 0x00000000000003FFULL,
+ 0x00000000000007FFULL,
+ 0x0000000000000FFFULL,
+ 0x0000000000001FFFULL,
+ 0x0000000000003FFFULL,
+ 0x0000000000007FFFULL,
+ 0x000000000000FFFFULL,
+ 0x000000000001FFFFULL,
+ 0x000000000003FFFFULL,
+ 0x000000000007FFFFULL,
+ 0x00000000000FFFFFULL,
+ 0x00000000001FFFFFULL,
+ 0x00000000003FFFFFULL,
+ 0x00000000007FFFFFULL,
+ 0x0000000000FFFFFFULL,
+ 0x0000000001FFFFFFULL,
+ 0x0000000003FFFFFFULL,
+ 0x0000000007FFFFFFULL,
+ 0x000000000FFFFFFFULL,
+ 0x000000001FFFFFFFULL,
+ 0x000000003FFFFFFFULL,
+ 0x000000007FFFFFFFULL,
+ 0x00000000FFFFFFFFULL,
+ 0x00000001FFFFFFFFULL,
+ 0x00000003FFFFFFFFULL,
+ 0x00000007FFFFFFFFULL,
+ 0x0000000FFFFFFFFFULL,
+ 0x0000001FFFFFFFFFULL,
+ 0x0000003FFFFFFFFFULL,
+ 0x0000007FFFFFFFFFULL,
+ 0x000000FFFFFFFFFFULL,
+ 0x000001FFFFFFFFFFULL,
+ 0x000003FFFFFFFFFFULL,
+ 0x000007FFFFFFFFFFULL,
+ 0x00000FFFFFFFFFFFULL,
+ 0x00001FFFFFFFFFFFULL,
+ 0x00003FFFFFFFFFFFULL,
+ 0x00007FFFFFFFFFFFULL,
+ 0x0000FFFFFFFFFFFFULL,
+ 0x0001FFFFFFFFFFFFULL,
+ 0x0003FFFFFFFFFFFFULL,
+ 0x0007FFFFFFFFFFFFULL,
+ 0x000FFFFFFFFFFFFFULL,
+ 0x001FFFFFFFFFFFFFULL,
+ 0x003FFFFFFFFFFFFFULL,
+ 0x007FFFFFFFFFFFFFULL,
+ 0x00FFFFFFFFFFFFFFULL,
+ 0x01FFFFFFFFFFFFFFULL,
+ 0x03FFFFFFFFFFFFFFULL,
+ 0x07FFFFFFFFFFFFFFULL,
+ 0x0FFFFFFFFFFFFFFFULL,
+ 0x1FFFFFFFFFFFFFFFULL,
+ 0x3FFFFFFFFFFFFFFFULL,
+ 0x7FFFFFFFFFFFFFFFULL,
+ 0xFFFFFFFFFFFFFFFFULL,
+ };
+
+ const ui64 INVERSE_WORD_MASK[] = {
+ ~0x0000000000000000ULL,
+ ~0x0000000000000001ULL,
+ ~0x0000000000000003ULL,
+ ~0x0000000000000007ULL,
+ ~0x000000000000000FULL,
+ ~0x000000000000001FULL,
+ ~0x000000000000003FULL,
+ ~0x000000000000007FULL,
+ ~0x00000000000000FFULL,
+ ~0x00000000000001FFULL,
+ ~0x00000000000003FFULL,
+ ~0x00000000000007FFULL,
+ ~0x0000000000000FFFULL,
+ ~0x0000000000001FFFULL,
+ ~0x0000000000003FFFULL,
+ ~0x0000000000007FFFULL,
+ ~0x000000000000FFFFULL,
+ ~0x000000000001FFFFULL,
+ ~0x000000000003FFFFULL,
+ ~0x000000000007FFFFULL,
+ ~0x00000000000FFFFFULL,
+ ~0x00000000001FFFFFULL,
+ ~0x00000000003FFFFFULL,
+ ~0x00000000007FFFFFULL,
+ ~0x0000000000FFFFFFULL,
+ ~0x0000000001FFFFFFULL,
+ ~0x0000000003FFFFFFULL,
+ ~0x0000000007FFFFFFULL,
+ ~0x000000000FFFFFFFULL,
+ ~0x000000001FFFFFFFULL,
+ ~0x000000003FFFFFFFULL,
+ ~0x000000007FFFFFFFULL,
+ ~0x00000000FFFFFFFFULL,
+ ~0x00000001FFFFFFFFULL,
+ ~0x00000003FFFFFFFFULL,
+ ~0x00000007FFFFFFFFULL,
+ ~0x0000000FFFFFFFFFULL,
+ ~0x0000001FFFFFFFFFULL,
+ ~0x0000003FFFFFFFFFULL,
+ ~0x0000007FFFFFFFFFULL,
+ ~0x000000FFFFFFFFFFULL,
+ ~0x000001FFFFFFFFFFULL,
+ ~0x000003FFFFFFFFFFULL,
+ ~0x000007FFFFFFFFFFULL,
+ ~0x00000FFFFFFFFFFFULL,
+ ~0x00001FFFFFFFFFFFULL,
+ ~0x00003FFFFFFFFFFFULL,
+ ~0x00007FFFFFFFFFFFULL,
+ ~0x0000FFFFFFFFFFFFULL,
+ ~0x0001FFFFFFFFFFFFULL,
+ ~0x0003FFFFFFFFFFFFULL,
+ ~0x0007FFFFFFFFFFFFULL,
+ ~0x000FFFFFFFFFFFFFULL,
+ ~0x001FFFFFFFFFFFFFULL,
+ ~0x003FFFFFFFFFFFFFULL,
+ ~0x007FFFFFFFFFFFFFULL,
+ ~0x00FFFFFFFFFFFFFFULL,
+ ~0x01FFFFFFFFFFFFFFULL,
+ ~0x03FFFFFFFFFFFFFFULL,
+ ~0x07FFFFFFFFFFFFFFULL,
+ ~0x0FFFFFFFFFFFFFFFULL,
+ ~0x1FFFFFFFFFFFFFFFULL,
+ ~0x3FFFFFFFFFFFFFFFULL,
+ ~0x7FFFFFFFFFFFFFFFULL,
+ ~0xFFFFFFFFFFFFFFFFULL,
+ };
}
}
diff --git a/util/generic/bitops.h b/util/generic/bitops.h
index 2c60e3437f..2db15fc59b 100644
--- a/util/generic/bitops.h
+++ b/util/generic/bitops.h
@@ -3,16 +3,16 @@
#include "ylimits.h"
#include "typelist.h"
-#include <util/system/compiler.h>
+#include <util/system/compiler.h>
#include <util/system/yassert.h>
-#ifdef _MSC_VER
+#ifdef _MSC_VER
#include <intrin.h>
-#endif
-
+#endif
+
namespace NBitOps {
namespace NPrivate {
- template <unsigned N, typename T>
+ template <unsigned N, typename T>
struct TClp2Helper {
static Y_FORCE_INLINE T Calc(T t) noexcept {
const T prev = TClp2Helper<N / 2, T>::Calc(t);
@@ -21,272 +21,272 @@ namespace NBitOps {
}
};
- template <typename T>
+ template <typename T>
struct TClp2Helper<0u, T> {
static Y_FORCE_INLINE T Calc(T t) noexcept {
return t - 1;
}
};
- extern const ui64 WORD_MASK[];
- extern const ui64 INVERSE_WORD_MASK[];
-
- // see http://www-graphics.stanford.edu/~seander/bithacks.html#ReverseParallel
-
+ extern const ui64 WORD_MASK[];
+ extern const ui64 INVERSE_WORD_MASK[];
+
+ // see http://www-graphics.stanford.edu/~seander/bithacks.html#ReverseParallel
+
Y_FORCE_INLINE ui64 SwapOddEvenBits(ui64 v) {
- return ((v >> 1ULL) & 0x5555555555555555ULL) | ((v & 0x5555555555555555ULL) << 1ULL);
- }
-
+ return ((v >> 1ULL) & 0x5555555555555555ULL) | ((v & 0x5555555555555555ULL) << 1ULL);
+ }
+
Y_FORCE_INLINE ui64 SwapBitPairs(ui64 v) {
- return ((v >> 2ULL) & 0x3333333333333333ULL) | ((v & 0x3333333333333333ULL) << 2ULL);
- }
-
+ return ((v >> 2ULL) & 0x3333333333333333ULL) | ((v & 0x3333333333333333ULL) << 2ULL);
+ }
+
Y_FORCE_INLINE ui64 SwapNibbles(ui64 v) {
- return ((v >> 4ULL) & 0x0F0F0F0F0F0F0F0FULL) | ((v & 0x0F0F0F0F0F0F0F0FULL) << 4ULL);
- }
-
+ return ((v >> 4ULL) & 0x0F0F0F0F0F0F0F0FULL) | ((v & 0x0F0F0F0F0F0F0F0FULL) << 4ULL);
+ }
+
Y_FORCE_INLINE ui64 SwapOddEvenBytes(ui64 v) {
- return ((v >> 8ULL) & 0x00FF00FF00FF00FFULL) | ((v & 0x00FF00FF00FF00FFULL) << 8ULL);
- }
-
+ return ((v >> 8ULL) & 0x00FF00FF00FF00FFULL) | ((v & 0x00FF00FF00FF00FFULL) << 8ULL);
+ }
+
Y_FORCE_INLINE ui64 SwapBytePairs(ui64 v) {
- return ((v >> 16ULL) & 0x0000FFFF0000FFFFULL) | ((v & 0x0000FFFF0000FFFFULL) << 16ULL);
- }
-
+ return ((v >> 16ULL) & 0x0000FFFF0000FFFFULL) | ((v & 0x0000FFFF0000FFFFULL) << 16ULL);
+ }
+
Y_FORCE_INLINE ui64 SwapByteQuads(ui64 v) {
- return (v >> 32ULL) | (v << 32ULL);
- }
-
+ return (v >> 32ULL) | (v << 32ULL);
+ }
+
#if defined(__GNUC__)
inline unsigned GetValueBitCountImpl(unsigned int value) noexcept {
- Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
- return std::numeric_limits<unsigned int>::digits - __builtin_clz(value);
- }
+ Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
+ return std::numeric_limits<unsigned int>::digits - __builtin_clz(value);
+ }
inline unsigned GetValueBitCountImpl(unsigned long value) noexcept {
- Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
- return std::numeric_limits<unsigned long>::digits - __builtin_clzl(value);
- }
+ Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
+ return std::numeric_limits<unsigned long>::digits - __builtin_clzl(value);
+ }
inline unsigned GetValueBitCountImpl(unsigned long long value) noexcept {
- Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
- return std::numeric_limits<unsigned long long>::digits - __builtin_clzll(value);
- }
-#else
- /// Stupid realization for non-GCC. Can use BSR from x86 instructions set.
- template <typename T>
+ Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
+ return std::numeric_limits<unsigned long long>::digits - __builtin_clzll(value);
+ }
+#else
+ /// Stupid realization for non-GCC. Can use BSR from x86 instructions set.
+ template <typename T>
inline unsigned GetValueBitCountImpl(T value) noexcept {
- Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
- unsigned result = 1; // result == 0 - impossible value, see Y_ASSERT().
- value >>= 1;
- while (value) {
- value >>= 1;
+ Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
+ unsigned result = 1; // result == 0 - impossible value, see Y_ASSERT().
+ value >>= 1;
+ while (value) {
+ value >>= 1;
++result;
- }
+ }
- return result;
- }
-#endif
+ return result;
+ }
+#endif
#if defined(__GNUC__)
inline unsigned CountTrailingZeroBitsImpl(unsigned int value) noexcept {
- Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
- return __builtin_ctz(value);
- }
+ Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
+ return __builtin_ctz(value);
+ }
inline unsigned CountTrailingZeroBitsImpl(unsigned long value) noexcept {
- Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
- return __builtin_ctzl(value);
- }
+ Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
+ return __builtin_ctzl(value);
+ }
inline unsigned CountTrailingZeroBitsImpl(unsigned long long value) noexcept {
- Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
- return __builtin_ctzll(value);
- }
-#else
- /// Stupid realization for non-GCC. Can use BSF from x86 instructions set.
- template <typename T>
+ Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
+ return __builtin_ctzll(value);
+ }
+#else
+ /// Stupid realization for non-GCC. Can use BSF from x86 instructions set.
+ template <typename T>
inline unsigned CountTrailingZeroBitsImpl(T value) noexcept {
- Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
- unsigned result = 0;
- while (!(value & 1)) {
- value >>= 1;
- ++result;
- }
-
- return result;
- }
-#endif
-
- template <typename T>
- Y_FORCE_INLINE T RotateBitsLeftImpl(T value, const ui8 shift) noexcept {
- constexpr ui8 bits = sizeof(T) * 8;
- constexpr ui8 mask = bits - 1;
- Y_ASSERT(shift <= mask);
-
- // do trick with mask to avoid undefined behaviour
- return (value << shift) | (value >> ((-shift) & mask));
- }
-
- template <typename T>
- Y_FORCE_INLINE T RotateBitsRightImpl(T value, const ui8 shift) noexcept {
- constexpr ui8 bits = sizeof(T) * 8;
- constexpr ui8 mask = bits - 1;
- Y_ASSERT(shift <= mask);
-
- // do trick with mask to avoid undefined behaviour
- return (value >> shift) | (value << ((-shift) & mask));
- }
-
-#if defined(_x86_) && defined(__GNUC__)
- Y_FORCE_INLINE ui8 RotateBitsRightImpl(ui8 value, ui8 shift) noexcept {
- __asm__("rorb %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
-
- Y_FORCE_INLINE ui16 RotateBitsRightImpl(ui16 value, ui8 shift) noexcept {
- __asm__("rorw %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
-
- Y_FORCE_INLINE ui32 RotateBitsRightImpl(ui32 value, ui8 shift) noexcept {
- __asm__("rorl %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
-
- Y_FORCE_INLINE ui8 RotateBitsLeftImpl(ui8 value, ui8 shift) noexcept {
- __asm__("rolb %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
-
- Y_FORCE_INLINE ui16 RotateBitsLeftImpl(ui16 value, ui8 shift) noexcept {
- __asm__("rolw %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
-
- Y_FORCE_INLINE ui32 RotateBitsLeftImpl(ui32 value, ui8 shift) noexcept {
- __asm__("roll %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
-
+ Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
+ unsigned result = 0;
+ while (!(value & 1)) {
+ value >>= 1;
+ ++result;
+ }
+
+ return result;
+ }
+#endif
+
+ template <typename T>
+ Y_FORCE_INLINE T RotateBitsLeftImpl(T value, const ui8 shift) noexcept {
+ constexpr ui8 bits = sizeof(T) * 8;
+ constexpr ui8 mask = bits - 1;
+ Y_ASSERT(shift <= mask);
+
+ // do trick with mask to avoid undefined behaviour
+ return (value << shift) | (value >> ((-shift) & mask));
+ }
+
+ template <typename T>
+ Y_FORCE_INLINE T RotateBitsRightImpl(T value, const ui8 shift) noexcept {
+ constexpr ui8 bits = sizeof(T) * 8;
+ constexpr ui8 mask = bits - 1;
+ Y_ASSERT(shift <= mask);
+
+ // do trick with mask to avoid undefined behaviour
+ return (value >> shift) | (value << ((-shift) & mask));
+ }
+
+#if defined(_x86_) && defined(__GNUC__)
+ Y_FORCE_INLINE ui8 RotateBitsRightImpl(ui8 value, ui8 shift) noexcept {
+ __asm__("rorb %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
+
+ Y_FORCE_INLINE ui16 RotateBitsRightImpl(ui16 value, ui8 shift) noexcept {
+ __asm__("rorw %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
+
+ Y_FORCE_INLINE ui32 RotateBitsRightImpl(ui32 value, ui8 shift) noexcept {
+ __asm__("rorl %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
+
+ Y_FORCE_INLINE ui8 RotateBitsLeftImpl(ui8 value, ui8 shift) noexcept {
+ __asm__("rolb %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
+
+ Y_FORCE_INLINE ui16 RotateBitsLeftImpl(ui16 value, ui8 shift) noexcept {
+ __asm__("rolw %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
+
+ Y_FORCE_INLINE ui32 RotateBitsLeftImpl(ui32 value, ui8 shift) noexcept {
+ __asm__("roll %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
+
#if defined(_x86_64_)
- Y_FORCE_INLINE ui64 RotateBitsRightImpl(ui64 value, ui8 shift) noexcept {
- __asm__("rorq %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
-
- Y_FORCE_INLINE ui64 RotateBitsLeftImpl(ui64 value, ui8 shift) noexcept {
- __asm__("rolq %%cl, %0"
- : "=r"(value)
- : "0"(value), "c"(shift));
- return value;
- }
+ Y_FORCE_INLINE ui64 RotateBitsRightImpl(ui64 value, ui8 shift) noexcept {
+ __asm__("rorq %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
+
+ Y_FORCE_INLINE ui64 RotateBitsLeftImpl(ui64 value, ui8 shift) noexcept {
+ __asm__("rolq %%cl, %0"
+ : "=r"(value)
+ : "0"(value), "c"(shift));
+ return value;
+ }
#endif
-#endif
+#endif
}
}
-
-/**
+
+/**
* Computes the next power of 2 higher or equal to the integer parameter `t`.
- * If `t` is a power of 2 will return `t`.
- * Result is undefined for `t == 0`.
- */
+ * If `t` is a power of 2 will return `t`.
+ * Result is undefined for `t == 0`.
+ */
template <typename T>
static inline T FastClp2(T t) noexcept {
- Y_ASSERT(t > 0);
+ Y_ASSERT(t > 0);
using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
- return 1 + ::NBitOps::NPrivate::TClp2Helper<sizeof(TCvt) * 4, T>::Calc(static_cast<TCvt>(t));
+ return 1 + ::NBitOps::NPrivate::TClp2Helper<sizeof(TCvt) * 4, T>::Calc(static_cast<TCvt>(t));
}
-/**
- * Check if integer is a power of 2.
- */
-template <typename T>
+/**
+ * Check if integer is a power of 2.
+ */
+template <typename T>
Y_CONST_FUNCTION constexpr bool IsPowerOf2(T v) noexcept {
- return v > 0 && (v & (v - 1)) == 0;
-}
+ return v > 0 && (v & (v - 1)) == 0;
+}
-/**
- * Returns the number of leading 0-bits in `value`, starting at the most significant bit position.
- */
+/**
+ * Returns the number of leading 0-bits in `value`, starting at the most significant bit position.
+ */
template <typename T>
static inline unsigned GetValueBitCount(T value) noexcept {
- Y_ASSERT(value > 0);
+ Y_ASSERT(value > 0);
using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
- return ::NBitOps::NPrivate::GetValueBitCountImpl(static_cast<TCvt>(value));
+ return ::NBitOps::NPrivate::GetValueBitCountImpl(static_cast<TCvt>(value));
}
-/**
- * Returns the number of trailing 0-bits in `value`, starting at the least significant bit position
- */
-template <typename T>
+/**
+ * Returns the number of trailing 0-bits in `value`, starting at the least significant bit position
+ */
+template <typename T>
static inline unsigned CountTrailingZeroBits(T value) noexcept {
- Y_ASSERT(value > 0);
+ Y_ASSERT(value > 0);
using TCvt = typename ::TUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
- return ::NBitOps::NPrivate::CountTrailingZeroBitsImpl(static_cast<TCvt>(value));
+ return ::NBitOps::NPrivate::CountTrailingZeroBitsImpl(static_cast<TCvt>(value));
}
-
-/*
- * Returns 64-bit mask with `bits` lower bits set.
- */
+
+/*
+ * Returns 64-bit mask with `bits` lower bits set.
+ */
Y_FORCE_INLINE ui64 MaskLowerBits(ui64 bits) {
- return ::NBitOps::NPrivate::WORD_MASK[bits];
-}
-
-/*
- * Return 64-bit mask with `bits` set starting from `skipbits`.
- */
+ return ::NBitOps::NPrivate::WORD_MASK[bits];
+}
+
+/*
+ * Return 64-bit mask with `bits` set starting from `skipbits`.
+ */
Y_FORCE_INLINE ui64 MaskLowerBits(ui64 bits, ui64 skipbits) {
- return MaskLowerBits(bits) << skipbits;
-}
-
-/*
- * Return 64-bit mask with all bits set except for `bits` lower bits.
- */
+ return MaskLowerBits(bits) << skipbits;
+}
+
+/*
+ * Return 64-bit mask with all bits set except for `bits` lower bits.
+ */
Y_FORCE_INLINE ui64 InverseMaskLowerBits(ui64 bits) {
- return ::NBitOps::NPrivate::INVERSE_WORD_MASK[bits];
-}
-
-/*
- * Return 64-bit mask with all bits set except for `bits` bitst starting from `skipbits`.
- */
+ return ::NBitOps::NPrivate::INVERSE_WORD_MASK[bits];
+}
+
+/*
+ * Return 64-bit mask with all bits set except for `bits` bitst starting from `skipbits`.
+ */
Y_FORCE_INLINE ui64 InverseMaskLowerBits(ui64 bits, ui64 skipbits) {
- return ~MaskLowerBits(bits, skipbits);
-}
-
-/*
+ return ~MaskLowerBits(bits, skipbits);
+}
+
+/*
* Returns 0-based position of the most significant bit that is set. 0 for 0.
- */
+ */
Y_FORCE_INLINE ui64 MostSignificantBit(ui64 v) {
-#ifdef __GNUC__
- ui64 res = v ? (63 - __builtin_clzll(v)) : 0;
-#elif defined(_MSC_VER) && defined(_64_)
- unsigned long res = 0;
- if (v)
- _BitScanReverse64(&res, v);
-#else
- ui64 res = 0;
- if (v)
- while (v >>= 1)
+#ifdef __GNUC__
+ ui64 res = v ? (63 - __builtin_clzll(v)) : 0;
+#elif defined(_MSC_VER) && defined(_64_)
+ unsigned long res = 0;
+ if (v)
+ _BitScanReverse64(&res, v);
+#else
+ ui64 res = 0;
+ if (v)
+ while (v >>= 1)
++res;
-#endif
- return res;
-}
-
+#endif
+ return res;
+}
+
/**
* Returns 0-based position of the least significant bit that is set. 0 for 0.
*/
@@ -309,7 +309,7 @@ Y_FORCE_INLINE ui64 LeastSignificantBit(ui64 v) {
return res;
}
-/*
+/*
* Returns 0 - based position of the most significant bit (compile time)
* 0 for 0.
*/
@@ -318,112 +318,112 @@ constexpr ui64 MostSignificantBitCT(ui64 x) {
}
/*
- * Return rounded up binary logarithm of `x`.
- */
+ * Return rounded up binary logarithm of `x`.
+ */
Y_FORCE_INLINE ui8 CeilLog2(ui64 x) {
- return static_cast<ui8>(MostSignificantBit(x - 1)) + 1;
-}
-
+ return static_cast<ui8>(MostSignificantBit(x - 1)) + 1;
+}
+
Y_FORCE_INLINE ui8 ReverseBytes(ui8 t) {
- return t;
-}
-
+ return t;
+}
+
Y_FORCE_INLINE ui16 ReverseBytes(ui16 t) {
- return static_cast<ui16>(::NBitOps::NPrivate::SwapOddEvenBytes(t));
-}
-
+ return static_cast<ui16>(::NBitOps::NPrivate::SwapOddEvenBytes(t));
+}
+
Y_FORCE_INLINE ui32 ReverseBytes(ui32 t) {
- return static_cast<ui32>(::NBitOps::NPrivate::SwapBytePairs(
- ::NBitOps::NPrivate::SwapOddEvenBytes(t)));
-}
-
+ return static_cast<ui32>(::NBitOps::NPrivate::SwapBytePairs(
+ ::NBitOps::NPrivate::SwapOddEvenBytes(t)));
+}
+
Y_FORCE_INLINE ui64 ReverseBytes(ui64 t) {
- return ::NBitOps::NPrivate::SwapByteQuads((::NBitOps::NPrivate::SwapOddEvenBytes(t)));
-}
-
+ return ::NBitOps::NPrivate::SwapByteQuads((::NBitOps::NPrivate::SwapOddEvenBytes(t)));
+}
+
Y_FORCE_INLINE ui8 ReverseBits(ui8 t) {
- return static_cast<ui8>(::NBitOps::NPrivate::SwapNibbles(
- ::NBitOps::NPrivate::SwapBitPairs(
- ::NBitOps::NPrivate::SwapOddEvenBits(t))));
-}
-
+ return static_cast<ui8>(::NBitOps::NPrivate::SwapNibbles(
+ ::NBitOps::NPrivate::SwapBitPairs(
+ ::NBitOps::NPrivate::SwapOddEvenBits(t))));
+}
+
Y_FORCE_INLINE ui16 ReverseBits(ui16 t) {
- return static_cast<ui16>(::NBitOps::NPrivate::SwapOddEvenBytes(
- ::NBitOps::NPrivate::SwapNibbles(
- ::NBitOps::NPrivate::SwapBitPairs(
- ::NBitOps::NPrivate::SwapOddEvenBits(t)))));
-}
-
+ return static_cast<ui16>(::NBitOps::NPrivate::SwapOddEvenBytes(
+ ::NBitOps::NPrivate::SwapNibbles(
+ ::NBitOps::NPrivate::SwapBitPairs(
+ ::NBitOps::NPrivate::SwapOddEvenBits(t)))));
+}
+
Y_FORCE_INLINE ui32 ReverseBits(ui32 t) {
- return static_cast<ui32>(::NBitOps::NPrivate::SwapBytePairs(
- ::NBitOps::NPrivate::SwapOddEvenBytes(
- ::NBitOps::NPrivate::SwapNibbles(
- ::NBitOps::NPrivate::SwapBitPairs(
- ::NBitOps::NPrivate::SwapOddEvenBits(t))))));
-}
-
+ return static_cast<ui32>(::NBitOps::NPrivate::SwapBytePairs(
+ ::NBitOps::NPrivate::SwapOddEvenBytes(
+ ::NBitOps::NPrivate::SwapNibbles(
+ ::NBitOps::NPrivate::SwapBitPairs(
+ ::NBitOps::NPrivate::SwapOddEvenBits(t))))));
+}
+
Y_FORCE_INLINE ui64 ReverseBits(ui64 t) {
- return ::NBitOps::NPrivate::SwapByteQuads(
- ::NBitOps::NPrivate::SwapBytePairs(
- ::NBitOps::NPrivate::SwapOddEvenBytes(
- ::NBitOps::NPrivate::SwapNibbles(
- ::NBitOps::NPrivate::SwapBitPairs(
- ::NBitOps::NPrivate::SwapOddEvenBits(t))))));
-}
-
-/*
- * Reverse first `bits` bits
- * 1000111000111000 , bits = 6 => 1000111000000111
- */
-template <typename T>
+ return ::NBitOps::NPrivate::SwapByteQuads(
+ ::NBitOps::NPrivate::SwapBytePairs(
+ ::NBitOps::NPrivate::SwapOddEvenBytes(
+ ::NBitOps::NPrivate::SwapNibbles(
+ ::NBitOps::NPrivate::SwapBitPairs(
+ ::NBitOps::NPrivate::SwapOddEvenBits(t))))));
+}
+
+/*
+ * Reverse first `bits` bits
+ * 1000111000111000 , bits = 6 => 1000111000000111
+ */
+template <typename T>
Y_FORCE_INLINE T ReverseBits(T v, ui64 bits) {
return bits ? (T(v & ::InverseMaskLowerBits(bits)) | T(ReverseBits(T(v & ::MaskLowerBits(bits)))) >> ((ui64{sizeof(T)} << ui64{3}) - bits)) : v;
-}
-
-/*
- * Referse first `bits` bits starting from `skipbits` bits
- * 1000111000111000 , bits = 4, skipbits = 2 => 1000111000011100
- */
-template <typename T>
+}
+
+/*
+ * Referse first `bits` bits starting from `skipbits` bits
+ * 1000111000111000 , bits = 4, skipbits = 2 => 1000111000011100
+ */
+template <typename T>
Y_FORCE_INLINE T ReverseBits(T v, ui64 bits, ui64 skipbits) {
- return (T(ReverseBits((v >> skipbits), bits)) << skipbits) | T(v & MaskLowerBits(skipbits));
-}
-
-/* Rotate bits left. Also known as left circular shift.
- */
-template <typename T>
-Y_FORCE_INLINE T RotateBitsLeft(T value, const ui8 shift) noexcept {
- static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
- return ::NBitOps::NPrivate::RotateBitsLeftImpl((TFixedWidthUnsignedInt<T>)value, shift);
-}
-
-/* Rotate bits right. Also known as right circular shift.
- */
-template <typename T>
-Y_FORCE_INLINE T RotateBitsRight(T value, const ui8 shift) noexcept {
- static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
- return ::NBitOps::NPrivate::RotateBitsRightImpl((TFixedWidthUnsignedInt<T>)value, shift);
-}
-
-/* Rotate bits left. Also known as left circular shift.
- */
-template <typename T>
-constexpr T RotateBitsLeftCT(T value, const ui8 shift) noexcept {
- static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
-
- // do trick with mask to avoid undefined behaviour
- return (value << shift) | (value >> ((-shift) & (sizeof(T) * 8 - 1)));
-}
-
-/* Rotate bits right. Also known as right circular shift.
- */
-template <typename T>
-constexpr T RotateBitsRightCT(T value, const ui8 shift) noexcept {
- static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
-
- // do trick with mask to avoid undefined behaviour
- return (value >> shift) | (value << ((-shift) & (sizeof(T) * 8 - 1)));
-}
+ return (T(ReverseBits((v >> skipbits), bits)) << skipbits) | T(v & MaskLowerBits(skipbits));
+}
+
+/* Rotate bits left. Also known as left circular shift.
+ */
+template <typename T>
+Y_FORCE_INLINE T RotateBitsLeft(T value, const ui8 shift) noexcept {
+ static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
+ return ::NBitOps::NPrivate::RotateBitsLeftImpl((TFixedWidthUnsignedInt<T>)value, shift);
+}
+
+/* Rotate bits right. Also known as right circular shift.
+ */
+template <typename T>
+Y_FORCE_INLINE T RotateBitsRight(T value, const ui8 shift) noexcept {
+ static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
+ return ::NBitOps::NPrivate::RotateBitsRightImpl((TFixedWidthUnsignedInt<T>)value, shift);
+}
+
+/* Rotate bits left. Also known as left circular shift.
+ */
+template <typename T>
+constexpr T RotateBitsLeftCT(T value, const ui8 shift) noexcept {
+ static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
+
+ // do trick with mask to avoid undefined behaviour
+ return (value << shift) | (value >> ((-shift) & (sizeof(T) * 8 - 1)));
+}
+
+/* Rotate bits right. Also known as right circular shift.
+ */
+template <typename T>
+constexpr T RotateBitsRightCT(T value, const ui8 shift) noexcept {
+ static_assert(std::is_unsigned<T>::value, "must be unsigned arithmetic type");
+
+ // do trick with mask to avoid undefined behaviour
+ return (value >> shift) | (value << ((-shift) & (sizeof(T) * 8 - 1)));
+}
/* Remain `size` bits to current `offset` of `value`
size, offset are less than number of bits in size_type
diff --git a/util/generic/bitops_ut.cpp b/util/generic/bitops_ut.cpp
index 4a1a6b799e..d23c2b5c27 100644
--- a/util/generic/bitops_ut.cpp
+++ b/util/generic/bitops_ut.cpp
@@ -4,45 +4,45 @@
#include <util/string/builder.h>
-template <typename T>
-static void TestCTZ() {
- for (unsigned int i = 0; i < (sizeof(T) << 3); ++i) {
- UNIT_ASSERT_VALUES_EQUAL(CountTrailingZeroBits(T(1) << i), i);
- }
-}
-
-template <typename T>
-static void TestFastClp2ForEachPowerOf2() {
- for (size_t i = 0; i < sizeof(T) * 8 - 1; ++i) {
- const auto current = T(1) << i;
- UNIT_ASSERT_VALUES_EQUAL(FastClp2(current), current);
- }
-
- UNIT_ASSERT_VALUES_EQUAL(FastClp2(T(1)), T(1));
- for (size_t i = 1; i < sizeof(T) * 8 - 1; ++i) {
- for (size_t j = 0; j < i; ++j) {
- const auto value = (T(1) << i) | (T(1) << j);
- const auto next = T(1) << (i + 1);
- UNIT_ASSERT_VALUES_EQUAL(FastClp2(value), next);
- }
- }
-}
-
-template <typename T>
-static T ReverseBitsSlow(T v) {
- T r = v; // r will be reversed bits of v; first get LSB of v
- ui32 s = sizeof(v) * 8 - 1; // extra shift needed at end
-
- for (v >>= 1; v; v >>= 1) {
- r <<= 1;
- r |= v & 1;
+template <typename T>
+static void TestCTZ() {
+ for (unsigned int i = 0; i < (sizeof(T) << 3); ++i) {
+ UNIT_ASSERT_VALUES_EQUAL(CountTrailingZeroBits(T(1) << i), i);
+ }
+}
+
+template <typename T>
+static void TestFastClp2ForEachPowerOf2() {
+ for (size_t i = 0; i < sizeof(T) * 8 - 1; ++i) {
+ const auto current = T(1) << i;
+ UNIT_ASSERT_VALUES_EQUAL(FastClp2(current), current);
+ }
+
+ UNIT_ASSERT_VALUES_EQUAL(FastClp2(T(1)), T(1));
+ for (size_t i = 1; i < sizeof(T) * 8 - 1; ++i) {
+ for (size_t j = 0; j < i; ++j) {
+ const auto value = (T(1) << i) | (T(1) << j);
+ const auto next = T(1) << (i + 1);
+ UNIT_ASSERT_VALUES_EQUAL(FastClp2(value), next);
+ }
+ }
+}
+
+template <typename T>
+static T ReverseBitsSlow(T v) {
+ T r = v; // r will be reversed bits of v; first get LSB of v
+ ui32 s = sizeof(v) * 8 - 1; // extra shift needed at end
+
+ for (v >>= 1; v; v >>= 1) {
+ r <<= 1;
+ r |= v & 1;
--s;
- }
-
- r <<= s; // shift when v's highest bits are zero
- return r;
-}
-
+ }
+
+ r <<= s; // shift when v's highest bits are zero
+ return r;
+}
+
// DO_NOT_STYLE
Y_UNIT_TEST_SUITE(TBitOpsTest) {
Y_UNIT_TEST(TestCountTrailingZeroBits) {
@@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
TestFastClp2ForEachPowerOf2<unsigned long>();
TestFastClp2ForEachPowerOf2<unsigned long long>();
}
-
+
Y_UNIT_TEST(TestMask) {
for (ui32 i = 0; i < 64; ++i) {
UNIT_ASSERT_VALUES_EQUAL(MaskLowerBits(i), (ui64{1} << i) - 1);
@@ -79,8 +79,8 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(MaskLowerBits(i, i / 2), (ui64{1} << i) - 1 << (i / 2));
UNIT_ASSERT_VALUES_EQUAL(InverseMaskLowerBits(i, i / 2), ~MaskLowerBits(i, i / 2));
}
- }
-
+ }
+
Y_UNIT_TEST(TestMostSignificantBit) {
static_assert(MostSignificantBitCT(0) == 0, ".");
static_assert(MostSignificantBitCT(1) == 0, ".");
@@ -93,8 +93,8 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
for (ui32 i = 0; i < 63; ++i) {
UNIT_ASSERT_VALUES_EQUAL(i + 1, MostSignificantBit(ui64{3} << i));
}
- }
-
+ }
+
Y_UNIT_TEST(TestLeastSignificantBit) {
for (ui32 i = 0; i < 64; ++i) {
UNIT_ASSERT_VALUES_EQUAL(i, LeastSignificantBit(ui64{1} << i));
@@ -112,13 +112,13 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
Y_UNIT_TEST(TestCeilLog2) {
UNIT_ASSERT_VALUES_EQUAL(CeilLog2(ui64{1}), 1);
-
+
for (ui32 i = 2; i < 64; ++i) {
UNIT_ASSERT_VALUES_EQUAL(CeilLog2(ui64{1} << i), i);
UNIT_ASSERT_VALUES_EQUAL(CeilLog2((ui64{1} << i) | ui64{1}), i + 1);
}
- }
-
+ }
+
Y_UNIT_TEST(TestReverse) {
for (ui64 i = 0; i < 0x100; ++i) {
UNIT_ASSERT_VALUES_EQUAL(ReverseBits((ui8)i), ReverseBitsSlow((ui8)i));
@@ -129,23 +129,23 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(ReverseBits((ui32)~i), ReverseBitsSlow((ui32)~i));
UNIT_ASSERT_VALUES_EQUAL(ReverseBits((ui64)~i), ReverseBitsSlow((ui64)~i));
}
-
+
ui32 v = 0xF0F0F0F0; // 11110000111100001111000011110000
for (ui32 i = 0; i < 4; ++i) {
UNIT_ASSERT_VALUES_EQUAL(ReverseBits(v, i + 1), v);
UNIT_ASSERT_VALUES_EQUAL(ReverseBits(v, 4 + 2 * i, 4 - i), v);
}
-
+
UNIT_ASSERT_VALUES_EQUAL(ReverseBits(v, 8), 0xF0F0F00Fu);
UNIT_ASSERT_VALUES_EQUAL(ReverseBits(v, 8, 4), 0xF0F0FF00u);
-
+
for (ui32 i = 0; i < 0x10000; ++i) {
for (ui32 j = 0; j <= 32; ++j) {
UNIT_ASSERT_VALUES_EQUAL_C(i, ReverseBits(ReverseBits(i, j), j), (TString)(TStringBuilder() << i << " " << j));
}
- }
- }
-
+ }
+ }
+
Y_UNIT_TEST(TestRotateBitsLeft) {
static_assert(RotateBitsLeftCT<ui8>(0b00000000u, 0) == 0b00000000u, "");
static_assert(RotateBitsLeftCT<ui8>(0b00000001u, 0) == 0b00000001u, "");
@@ -155,7 +155,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsLeftCT<ui8>(0b00000101u, 1) == 0b00001010u, "");
static_assert(RotateBitsLeftCT<ui8>(0b10100000u, 1) == 0b01000001u, "");
static_assert(RotateBitsLeftCT<ui8>(0b10000000u, 7) == 0b01000000u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b00000000u, 0), 0b00000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b00000001u, 0), 0b00000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b10000000u, 0), 0b10000000u);
@@ -164,7 +164,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b00000101u, 1), 0b00001010u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b10100000u, 1), 0b01000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui8>(0b10000000u, 7), 0b01000000u);
-
+
static_assert(RotateBitsLeftCT<ui16>(0b0000000000000000u, 0) == 0b0000000000000000u, "");
static_assert(RotateBitsLeftCT<ui16>(0b0000000000000001u, 0) == 0b0000000000000001u, "");
static_assert(RotateBitsLeftCT<ui16>(0b1000000000000000u, 0) == 0b1000000000000000u, "");
@@ -173,7 +173,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsLeftCT<ui16>(0b0000000000000101u, 1) == 0b0000000000001010u, "");
static_assert(RotateBitsLeftCT<ui16>(0b1010000000000000u, 1) == 0b0100000000000001u, "");
static_assert(RotateBitsLeftCT<ui16>(0b1000000000000000u, 15) == 0b0100000000000000u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b0000000000000000u, 0), 0b0000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b0000000000000001u, 0), 0b0000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b1000000000000000u, 0), 0b1000000000000000u);
@@ -182,7 +182,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b0000000000000101u, 1), 0b0000000000001010u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b1010000000000000u, 1), 0b0100000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui16>(0b1000000000000000u, 15), 0b0100000000000000u);
-
+
static_assert(RotateBitsLeftCT<ui32>(0b00000000000000000000000000000000u, 0) == 0b00000000000000000000000000000000u, "");
static_assert(RotateBitsLeftCT<ui32>(0b00000000000000000000000000000001u, 0) == 0b00000000000000000000000000000001u, "");
static_assert(RotateBitsLeftCT<ui32>(0b10000000000000000000000000000000u, 0) == 0b10000000000000000000000000000000u, "");
@@ -191,7 +191,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsLeftCT<ui32>(0b00000000000000000000000000000101u, 1) == 0b00000000000000000000000000001010u, "");
static_assert(RotateBitsLeftCT<ui32>(0b10100000000000000000000000000000u, 1) == 0b01000000000000000000000000000001u, "");
static_assert(RotateBitsLeftCT<ui32>(0b10000000000000000000000000000000u, 31) == 0b01000000000000000000000000000000u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b00000000000000000000000000000000u, 0), 0b00000000000000000000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b00000000000000000000000000000001u, 0), 0b00000000000000000000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b10000000000000000000000000000000u, 0), 0b10000000000000000000000000000000u);
@@ -200,7 +200,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b00000000000000000000000000000101u, 1), 0b00000000000000000000000000001010u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b10100000000000000000000000000000u, 1), 0b01000000000000000000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui32>(0b10000000000000000000000000000000u, 31), 0b01000000000000000000000000000000u);
-
+
static_assert(RotateBitsLeftCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000000u, 0) == 0b0000000000000000000000000000000000000000000000000000000000000000u, "");
static_assert(RotateBitsLeftCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 0) == 0b0000000000000000000000000000000000000000000000000000000000000001u, "");
static_assert(RotateBitsLeftCT<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 0) == 0b1000000000000000000000000000000000000000000000000000000000000000u, "");
@@ -209,7 +209,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsLeftCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000101u, 1) == 0b0000000000000000000000000000000000000000000000000000000000001010u, "");
static_assert(RotateBitsLeftCT<ui64>(0b1010000000000000000000000000000000000000000000000000000000000000u, 1) == 0b0100000000000000000000000000000000000000000000000000000000000001u, "");
static_assert(RotateBitsLeftCT<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 63) == 0b0100000000000000000000000000000000000000000000000000000000000000u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui64>(0b0000000000000000000000000000000000000000000000000000000000000000u, 0), 0b0000000000000000000000000000000000000000000000000000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 0), 0b0000000000000000000000000000000000000000000000000000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 0), 0b1000000000000000000000000000000000000000000000000000000000000000u);
@@ -219,7 +219,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui64>(0b1010000000000000000000000000000000000000000000000000000000000000u, 1), 0b0100000000000000000000000000000000000000000000000000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsLeft<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 63), 0b0100000000000000000000000000000000000000000000000000000000000000u);
}
-
+
Y_UNIT_TEST(TestRotateBitsRight) {
static_assert(RotateBitsRightCT<ui8>(0b00000000u, 0) == 0b00000000u, "");
static_assert(RotateBitsRightCT<ui8>(0b00000001u, 0) == 0b00000001u, "");
@@ -229,7 +229,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsRightCT<ui8>(0b00000101u, 1) == 0b10000010u, "");
static_assert(RotateBitsRightCT<ui8>(0b10100000u, 1) == 0b01010000u, "");
static_assert(RotateBitsRightCT<ui8>(0b00000001u, 7) == 0b00000010u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b00000000u, 0), 0b00000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b00000001u, 0), 0b00000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b10000000u, 0), 0b10000000u);
@@ -238,7 +238,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b00000101u, 1), 0b10000010u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b10100000u, 1), 0b01010000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui8>(0b00000001u, 7), 0b00000010u);
-
+
static_assert(RotateBitsRightCT<ui16>(0b0000000000000000u, 0) == 0b0000000000000000u, "");
static_assert(RotateBitsRightCT<ui16>(0b0000000000000001u, 0) == 0b0000000000000001u, "");
static_assert(RotateBitsRightCT<ui16>(0b1000000000000000u, 0) == 0b1000000000000000u, "");
@@ -247,7 +247,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsRightCT<ui16>(0b0000000000000101u, 1) == 0b1000000000000010u, "");
static_assert(RotateBitsRightCT<ui16>(0b1010000000000000u, 1) == 0b0101000000000000u, "");
static_assert(RotateBitsRightCT<ui16>(0b0000000000000001u, 15) == 0b0000000000000010u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b0000000000000000u, 0), 0b0000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b0000000000000001u, 0), 0b0000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b1000000000000000u, 0), 0b1000000000000000u);
@@ -256,7 +256,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b0000000000000101u, 1), 0b1000000000000010u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b1010000000000000u, 1), 0b0101000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui16>(0b0000000000000001u, 15), 0b0000000000000010u);
-
+
static_assert(RotateBitsRightCT<ui32>(0b00000000000000000000000000000000u, 0) == 0b00000000000000000000000000000000u, "");
static_assert(RotateBitsRightCT<ui32>(0b00000000000000000000000000000001u, 0) == 0b00000000000000000000000000000001u, "");
static_assert(RotateBitsRightCT<ui32>(0b10000000000000000000000000000000u, 0) == 0b10000000000000000000000000000000u, "");
@@ -265,7 +265,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsRightCT<ui32>(0b00000000000000000000000000000101u, 1) == 0b10000000000000000000000000000010u, "");
static_assert(RotateBitsRightCT<ui32>(0b10100000000000000000000000000000u, 1) == 0b01010000000000000000000000000000u, "");
static_assert(RotateBitsRightCT<ui32>(0b00000000000000000000000000000001u, 31) == 0b00000000000000000000000000000010u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b00000000000000000000000000000000u, 0), 0b00000000000000000000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b00000000000000000000000000000001u, 0), 0b00000000000000000000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b10000000000000000000000000000000u, 0), 0b10000000000000000000000000000000u);
@@ -274,7 +274,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b00000000000000000000000000000101u, 1), 0b10000000000000000000000000000010u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b10100000000000000000000000000000u, 1), 0b01010000000000000000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui32>(0b00000000000000000000000000000001u, 31), 0b00000000000000000000000000000010u);
-
+
static_assert(RotateBitsRightCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000000u, 0) == 0b0000000000000000000000000000000000000000000000000000000000000000u, "");
static_assert(RotateBitsRightCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 0) == 0b0000000000000000000000000000000000000000000000000000000000000001u, "");
static_assert(RotateBitsRightCT<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 0) == 0b1000000000000000000000000000000000000000000000000000000000000000u, "");
@@ -283,7 +283,7 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
static_assert(RotateBitsRightCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000101u, 1) == 0b1000000000000000000000000000000000000000000000000000000000000010u, "");
static_assert(RotateBitsRightCT<ui64>(0b1010000000000000000000000000000000000000000000000000000000000000u, 1) == 0b0101000000000000000000000000000000000000000000000000000000000000u, "");
static_assert(RotateBitsRightCT<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 63) == 0b0000000000000000000000000000000000000000000000000000000000000010u, "");
-
+
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui64>(0b0000000000000000000000000000000000000000000000000000000000000000u, 0), 0b0000000000000000000000000000000000000000000000000000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 0), 0b0000000000000000000000000000000000000000000000000000000000000001u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui64>(0b1000000000000000000000000000000000000000000000000000000000000000u, 0), 0b1000000000000000000000000000000000000000000000000000000000000000u);
diff --git a/util/generic/buffer.cpp b/util/generic/buffer.cpp
index dd60963873..b92697e1d0 100644
--- a/util/generic/buffer.cpp
+++ b/util/generic/buffer.cpp
@@ -7,7 +7,7 @@
#include <util/system/sanitizers.h>
TBuffer::TBuffer(size_t len)
- : Data_(nullptr)
+ : Data_(nullptr)
, Len_(0)
, Pos_(0)
{
@@ -23,7 +23,7 @@ TBuffer::TBuffer(TBuffer&& b) noexcept
}
TBuffer::TBuffer(const char* buf, size_t len)
- : Data_(nullptr)
+ : Data_(nullptr)
, Len_(0)
, Pos_(0)
{
@@ -76,14 +76,14 @@ void TBuffer::DoReserve(size_t realLen) {
// FastClp2<T>(x) returns 0 on x from [Max<T>/2 + 2, Max<T>]
const size_t len = Max<size_t>(FastClp2(realLen), realLen);
- Y_ASSERT(realLen > Len_);
- Y_ASSERT(len >= realLen);
+ Y_ASSERT(realLen > Len_);
+ Y_ASSERT(len >= realLen);
Realloc(len);
}
void TBuffer::Realloc(size_t len) {
- Y_ASSERT(Pos_ <= len);
+ Y_ASSERT(Pos_ <= len);
Data_ = (char*)y_reallocate(Data_, len);
Len_ = len;
diff --git a/util/generic/buffer.h b/util/generic/buffer.h
index ee3e92e90d..9576467404 100644
--- a/util/generic/buffer.h
+++ b/util/generic/buffer.h
@@ -42,7 +42,7 @@ public:
}
inline void EraseBack(size_t n) noexcept {
- Y_ASSERT(n <= Pos_);
+ Y_ASSERT(n <= Pos_);
Pos_ -= n;
}
@@ -131,7 +131,7 @@ public:
}
inline void Proceed(size_t pos) {
- //Y_ASSERT(pos <= Len_); // see discussion in REVIEW:29021
+ //Y_ASSERT(pos <= Len_); // see discussion in REVIEW:29021
Resize(pos);
}
diff --git a/util/generic/buffer_ut.cpp b/util/generic/buffer_ut.cpp
index 3f1114018c..437d7122ec 100644
--- a/util/generic/buffer_ut.cpp
+++ b/util/generic/buffer_ut.cpp
@@ -5,8 +5,8 @@
#include "vector.h"
#include "buffer.h"
-Y_UNIT_TEST_SUITE(TBufferTest) {
- Y_UNIT_TEST(TestEraseBack) {
+Y_UNIT_TEST_SUITE(TBufferTest) {
+ Y_UNIT_TEST(TestEraseBack) {
TBuffer buf;
buf.Append("1234567", 7);
@@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
UNIT_ASSERT_EQUAL(TString(buf.data(), buf.size()), "1234");
}
- Y_UNIT_TEST(TestAppend) {
+ Y_UNIT_TEST(TestAppend) {
const char data[] = "1234567890qwertyuiop";
TBuffer buf(13);
@@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
UNIT_ASSERT_EQUAL(TString(buf.data(), buf.size()), str);
}
- Y_UNIT_TEST(TestReset) {
+ Y_UNIT_TEST(TestReset) {
char content[] = "some text";
TBuffer buf;
@@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
UNIT_ASSERT_EQUAL(buf.Capacity(), 0);
}
- Y_UNIT_TEST(TestResize) {
+ Y_UNIT_TEST(TestResize) {
char content[] = "some text";
TBuffer buf;
@@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
UNIT_ASSERT_VALUES_EQUAL(TString(buf.data(), buf.size()), "some");
}
- Y_UNIT_TEST(TestReserve) {
+ Y_UNIT_TEST(TestReserve) {
TBuffer buf;
UNIT_ASSERT_EQUAL(buf.Capacity(), 0);
@@ -101,7 +101,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
UNIT_ASSERT_EQUAL(buf.Capacity(), 2048);
}
- Y_UNIT_TEST(TestShrinkToFit) {
+ Y_UNIT_TEST(TestShrinkToFit) {
TBuffer buf;
TString content = "some text";
@@ -126,7 +126,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
}
#if 0
-Y_UNIT_TEST(TestAlignUp) {
+Y_UNIT_TEST(TestAlignUp) {
char content[] = "some text";
TBuffer buf;
@@ -145,7 +145,7 @@ Y_UNIT_TEST(TestAlignUp) {
#endif
#if 0
-Y_UNIT_TEST(TestSpeed) {
+Y_UNIT_TEST(TestSpeed) {
const char data[] = "1234567890qwertyuiop";
const size_t c = 100000;
ui64 t1 = 0;
@@ -179,7 +179,7 @@ Y_UNIT_TEST(TestSpeed) {
}
#endif
- Y_UNIT_TEST(TestFillAndChop) {
+ Y_UNIT_TEST(TestFillAndChop) {
TBuffer buf;
buf.Append("Some ", 5);
buf.Fill('!', 5);
diff --git a/util/generic/cast.h b/util/generic/cast.h
index e1807ce1d8..0d4a41f385 100644
--- a/util/generic/cast.h
+++ b/util/generic/cast.h
@@ -13,12 +13,12 @@
template <class T, class F>
static inline T VerifyDynamicCast(F f) {
if (!f) {
- return nullptr;
+ return nullptr;
}
T ret = dynamic_cast<T>(f);
- Y_VERIFY(ret, "verify cast failed");
+ Y_VERIFY(ret, "verify cast failed");
return ret;
}
@@ -68,7 +68,7 @@ template <>
class TInteger<true> {
public:
template <class TUnsigned>
- static constexpr bool IsNegative(TUnsigned) noexcept {
+ static constexpr bool IsNegative(TUnsigned) noexcept {
return false;
}
};
@@ -77,13 +77,13 @@ template <>
class TInteger<false> {
public:
template <class TSigned>
- static constexpr bool IsNegative(const TSigned value) noexcept {
+ static constexpr bool IsNegative(const TSigned value) noexcept {
return value < 0;
}
};
template <class TType>
-constexpr bool IsNegative(const TType value) noexcept {
+constexpr bool IsNegative(const TType value) noexcept {
return TInteger<std::is_unsigned<TType>::value>::IsNegative(value);
}
@@ -93,7 +93,7 @@ namespace NPrivate {
std::is_enum<T>::value,
std::underlying_type<T>, // Lazy evaluatuion: do not call ::type here, because underlying_type<T> is undefined if T is not an enum.
std::enable_if<true, T> // Wrapping T in a class, that has member ::type typedef.
- >::type::type; // Left ::type is for std::conditional, right ::type is for underlying_type/enable_if
+ >::type::type; // Left ::type is for std::conditional, right ::type is for underlying_type/enable_if
template <class TSmall, class TLarge>
struct TSafelyConvertible {
@@ -112,15 +112,15 @@ constexpr std::enable_if_t<::NPrivate::TSafelyConvertible<TSmallInt, TLargeInt>:
}
template <class TSmall, class TLarge>
-inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result, TSmall> SafeIntegerCast(TLarge largeInt) {
+inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result, TSmall> SafeIntegerCast(TLarge largeInt) {
using TSmallInt = ::NPrivate::TUnderlyingTypeOrSelf<TSmall>;
using TLargeInt = ::NPrivate::TUnderlyingTypeOrSelf<TLarge>;
if (std::is_unsigned<TSmallInt>::value && std::is_signed<TLargeInt>::value) {
if (IsNegative(largeInt)) {
ythrow TBadCastException() << "Conversion '" << TypeName<TLarge>() << '{' << TLargeInt(largeInt) << "}' to '"
- << TypeName<TSmallInt>()
- << "', negative value converted to unsigned";
+ << TypeName<TSmallInt>()
+ << "', negative value converted to unsigned";
}
}
@@ -129,14 +129,14 @@ inline std::enable_if_t<!::NPrivate::TSafelyConvertible<TSmall, TLarge>::Result,
if (std::is_signed<TSmallInt>::value && std::is_unsigned<TLargeInt>::value) {
if (IsNegative(smallInt)) {
ythrow TBadCastException() << "Conversion '" << TypeName<TLarge>() << '{' << TLargeInt(largeInt) << "}' to '"
- << TypeName<TSmallInt>()
- << "', positive value converted to negative";
+ << TypeName<TSmallInt>()
+ << "', positive value converted to negative";
}
}
if (TLargeInt(smallInt) != largeInt) {
ythrow TBadCastException() << "Conversion '" << TypeName<TLarge>() << '{' << TLargeInt(largeInt) << "}' to '"
- << TypeName<TSmallInt>() << "', loss of data";
+ << TypeName<TSmallInt>() << "', loss of data";
}
return static_cast<TSmall>(smallInt);
@@ -147,17 +147,17 @@ inline TSmallInt IntegerCast(TLargeInt largeInt) noexcept {
try {
return SafeIntegerCast<TSmallInt>(largeInt);
} catch (const yexception& exc) {
- Y_FAIL("IntegerCast: %s", exc.what());
+ Y_FAIL("IntegerCast: %s", exc.what());
}
}
-
-/* Convert given enum value to its underlying type. This is just a shortcut for
- * `static_cast<std::underlying_type_t<EEnum>>(enum_)`.
- */
-template <typename T>
-constexpr std::underlying_type_t<T> ToUnderlying(const T enum_) noexcept {
- return static_cast<std::underlying_type_t<T>>(enum_);
-}
+
+/* Convert given enum value to its underlying type. This is just a shortcut for
+ * `static_cast<std::underlying_type_t<EEnum>>(enum_)`.
+ */
+template <typename T>
+constexpr std::underlying_type_t<T> ToUnderlying(const T enum_) noexcept {
+ return static_cast<std::underlying_type_t<T>>(enum_);
+}
// std::bit_cast from c++20
template <class TTarget, class TSource>
diff --git a/util/generic/cast_ut.cpp b/util/generic/cast_ut.cpp
index 0ab58f2efc..718a8de79d 100644
--- a/util/generic/cast_ut.cpp
+++ b/util/generic/cast_ut.cpp
@@ -7,7 +7,7 @@ class TGenericCastsTest: public TTestBase {
UNIT_TEST(TestVerifyDynamicCast)
UNIT_TEST(TestIntegralCast)
UNIT_TEST(TestEnumCast)
- UNIT_TEST(TestToUnderlying)
+ UNIT_TEST(TestToUnderlying)
UNIT_TEST(TestBitCast)
UNIT_TEST_SUITE_END();
@@ -55,32 +55,32 @@ private:
UNIT_ASSERT(SafeIntegerCast<B>(-1) == BM1);
UNIT_ASSERT(SafeIntegerCast<C>(1) == C::CM1);
}
-
- void TestToUnderlying() {
- enum A {
- AM1 = -1
- };
-
+
+ void TestToUnderlying() {
+ enum A {
+ AM1 = -1
+ };
+
enum B: int {
- BM1 = -1
- };
-
+ BM1 = -1
+ };
+
enum class C: unsigned short {
- CM1 = 1
- };
-
- static_assert(static_cast<std::underlying_type_t<A>>(AM1) == ToUnderlying(AM1), "");
- static_assert(static_cast<std::underlying_type_t<B>>(BM1) == ToUnderlying(BM1), "");
- static_assert(static_cast<std::underlying_type_t<C>>(C::CM1) == ToUnderlying(C::CM1), "");
-
- static_assert(std::is_same<std::underlying_type_t<A>, decltype(ToUnderlying(AM1))>::value, "");
- static_assert(std::is_same<std::underlying_type_t<B>, decltype(ToUnderlying(BM1))>::value, "");
- static_assert(std::is_same<std::underlying_type_t<C>, decltype(ToUnderlying(C::CM1))>::value, "");
-
- UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<A>>(AM1), ToUnderlying(AM1));
- UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<B>>(BM1), ToUnderlying(BM1));
- UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<C>>(C::CM1), ToUnderlying(C::CM1));
- }
+ CM1 = 1
+ };
+
+ static_assert(static_cast<std::underlying_type_t<A>>(AM1) == ToUnderlying(AM1), "");
+ static_assert(static_cast<std::underlying_type_t<B>>(BM1) == ToUnderlying(BM1), "");
+ static_assert(static_cast<std::underlying_type_t<C>>(C::CM1) == ToUnderlying(C::CM1), "");
+
+ static_assert(std::is_same<std::underlying_type_t<A>, decltype(ToUnderlying(AM1))>::value, "");
+ static_assert(std::is_same<std::underlying_type_t<B>, decltype(ToUnderlying(BM1))>::value, "");
+ static_assert(std::is_same<std::underlying_type_t<C>, decltype(ToUnderlying(C::CM1))>::value, "");
+
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<A>>(AM1), ToUnderlying(AM1));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<B>>(BM1), ToUnderlying(BM1));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<std::underlying_type_t<C>>(C::CM1), ToUnderlying(C::CM1));
+ }
void TestBitCast() {
// Change sign of float
diff --git a/util/generic/explicit_type.h b/util/generic/explicit_type.h
index e43b8455f7..34e269f155 100644
--- a/util/generic/explicit_type.h
+++ b/util/generic/explicit_type.h
@@ -24,7 +24,7 @@ template <class T>
class TExplicitType {
public:
template <class OtherT>
- TExplicitType(const OtherT& value, std::enable_if_t<std::is_same<OtherT, T>::value>* = nullptr) noexcept
+ TExplicitType(const OtherT& value, std::enable_if_t<std::is_same<OtherT, T>::value>* = nullptr) noexcept
: Value_(value)
{
}
diff --git a/util/generic/explicit_type_ut.cpp b/util/generic/explicit_type_ut.cpp
index 2811e789f2..50a745f090 100644
--- a/util/generic/explicit_type_ut.cpp
+++ b/util/generic/explicit_type_ut.cpp
@@ -38,8 +38,8 @@ struct IntConstructible {
}
};
-Y_UNIT_TEST_SUITE(TestExplicitType) {
- Y_UNIT_TEST(Test1) {
+Y_UNIT_TEST_SUITE(TestExplicitType) {
+ Y_UNIT_TEST(Test1) {
UNIT_ASSERT_VALUES_EQUAL(static_cast<bool>(TCallable<TExplicitlyCallable<char>, char>::Result), true);
UNIT_ASSERT_VALUES_EQUAL(static_cast<bool>(TCallable<TExplicitlyCallable<char>, int>::Result), false);
UNIT_ASSERT_VALUES_EQUAL(static_cast<bool>(TCallable<TExplicitlyCallable<char>, wchar_t>::Result), false);
diff --git a/util/generic/fastqueue.h b/util/generic/fastqueue.h
index 6f01fec4d6..1fee5b86f6 100644
--- a/util/generic/fastqueue.h
+++ b/util/generic/fastqueue.h
@@ -27,7 +27,7 @@ public:
}
inline T Pop() {
- Y_ASSERT(!this->Empty());
+ Y_ASSERT(!this->Empty());
THolder<THelper> tmp(Queue_.PopBack());
--Size_;
diff --git a/util/generic/flags.cpp b/util/generic/flags.cpp
index f16a643562..2ee52188a0 100644
--- a/util/generic/flags.cpp
+++ b/util/generic/flags.cpp
@@ -3,26 +3,26 @@
#include <util/stream/format.h>
#include <util/system/yassert.h>
-void ::NPrivate::PrintFlags(IOutputStream& stream, ui64 value, size_t size) {
+void ::NPrivate::PrintFlags(IOutputStream& stream, ui64 value, size_t size) {
/* Note that this function is in cpp because we need to break circular
* dependency between TFlags and ENumberFormat. */
stream << "TFlags(";
switch (size) {
- case 1:
- stream << Bin(static_cast<ui8>(value), HF_FULL);
- break;
- case 2:
- stream << Bin(static_cast<ui16>(value), HF_FULL);
- break;
- case 4:
- stream << Bin(static_cast<ui32>(value), HF_FULL);
- break;
- case 8:
- stream << Bin(static_cast<ui64>(value), HF_FULL);
- break;
- default:
- Y_VERIFY(false);
+ case 1:
+ stream << Bin(static_cast<ui8>(value), HF_FULL);
+ break;
+ case 2:
+ stream << Bin(static_cast<ui16>(value), HF_FULL);
+ break;
+ case 4:
+ stream << Bin(static_cast<ui32>(value), HF_FULL);
+ break;
+ case 8:
+ stream << Bin(static_cast<ui64>(value), HF_FULL);
+ break;
+ default:
+ Y_VERIFY(false);
}
stream << ")";
diff --git a/util/generic/flags.h b/util/generic/flags.h
index 3b0eb4a2e2..a1f5921d42 100644
--- a/util/generic/flags.h
+++ b/util/generic/flags.h
@@ -6,9 +6,9 @@
#include <util/generic/typetraits.h>
#include <util/generic/fwd.h>
-class IOutputStream;
+class IOutputStream;
namespace NPrivate {
- void PrintFlags(IOutputStream& stream, ui64 value, size_t size);
+ void PrintFlags(IOutputStream& stream, ui64 value, size_t size);
}
/**
@@ -34,10 +34,10 @@ namespace NPrivate {
template <class Enum>
class TFlags {
static_assert(std::is_enum<Enum>::value, "Expecting an enumeration here.");
-
+
public:
using TEnum = Enum;
- using TInt = std::underlying_type_t<Enum>;
+ using TInt = std::underlying_type_t<Enum>;
constexpr TFlags(std::nullptr_t = 0)
: Value_(0)
@@ -79,18 +79,18 @@ public:
return TFlags(TFlag(l.Value_ ^ r.Value_));
}
- constexpr friend TFlags
- operator^(TEnum l, TFlags r) {
+ constexpr friend TFlags
+ operator^(TEnum l, TFlags r) {
return TFlags(TFlag(static_cast<TInt>(l) ^ r.Value_));
}
- constexpr friend TFlags
- operator^(TFlags l, TEnum r) {
+ constexpr friend TFlags
+ operator^(TFlags l, TEnum r) {
return TFlags(TFlag(l.Value_ ^ static_cast<TInt>(r)));
}
- constexpr friend TFlags
- operator&(TFlags l, TFlags r) {
+ constexpr friend TFlags
+ operator&(TFlags l, TFlags r) {
return TFlags(TFlag(l.Value_ & r.Value_));
}
@@ -177,7 +177,7 @@ public:
return *this;
}
- friend IOutputStream& operator<<(IOutputStream& stream, const TFlags& flags) {
+ friend IOutputStream& operator<<(IOutputStream& stream, const TFlags& flags) {
::NPrivate::PrintFlags(stream, static_cast<ui64>(flags.Value_), sizeof(TInt));
return stream;
}
diff --git a/util/generic/flags_ut.cpp b/util/generic/flags_ut.cpp
index 9290f55099..5377c6a058 100644
--- a/util/generic/flags_ut.cpp
+++ b/util/generic/flags_ut.cpp
@@ -31,7 +31,7 @@ namespace {
Y_DECLARE_OPERATORS_FOR_FLAGS(ETestFlags3)
}
-Y_UNIT_TEST_SUITE(TFlagsTest) {
+Y_UNIT_TEST_SUITE(TFlagsTest) {
template <class Enum>
void TestEnum() {
{
@@ -66,12 +66,12 @@ Y_UNIT_TEST_SUITE(TFlagsTest) {
}
}
- Y_UNIT_TEST(TestFlags) {
+ Y_UNIT_TEST(TestFlags) {
TestEnum<ETestFlag1>();
TestEnum<ETestFlag2>();
}
- Y_UNIT_TEST(TestZero) {
+ Y_UNIT_TEST(TestZero) {
/* This code should simply compile. */
ETest1 f = 0;
@@ -82,7 +82,7 @@ Y_UNIT_TEST_SUITE(TFlagsTest) {
ff = 0;
}
- Y_UNIT_TEST(TestOutput) {
+ Y_UNIT_TEST(TestOutput) {
ETest1 value0 = nullptr, value1 = Test1, value7 = Test1 | Test2 | Test4;
UNIT_ASSERT_VALUES_EQUAL(ToString(value0), "TFlags(0000000000000000)");
@@ -90,7 +90,7 @@ Y_UNIT_TEST_SUITE(TFlagsTest) {
UNIT_ASSERT_VALUES_EQUAL(ToString(value7), "TFlags(0000000000000111)");
}
- Y_UNIT_TEST(TestHash) {
+ Y_UNIT_TEST(TestHash) {
ETest1 value0 = nullptr, value1 = Test1;
THashMap<ETest1, int> hash;
@@ -101,7 +101,7 @@ Y_UNIT_TEST_SUITE(TFlagsTest) {
UNIT_ASSERT_VALUES_EQUAL(hash[value1], 1);
}
- Y_UNIT_TEST(TestBaseType) {
+ Y_UNIT_TEST(TestBaseType) {
ui16 goodValue = 7;
auto goodFlags = ETest1::FromBaseType(goodValue);
UNIT_ASSERT(goodFlags& ETestFlag1::Test1);
diff --git a/util/generic/function_ut.cpp b/util/generic/function_ut.cpp
index 730d2dc7de..3880295a9f 100644
--- a/util/generic/function_ut.cpp
+++ b/util/generic/function_ut.cpp
@@ -3,7 +3,7 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TestFunctionSignature) {
+Y_UNIT_TEST_SUITE(TestFunctionSignature) {
int FF(double x) {
return (int)x;
}
@@ -18,15 +18,15 @@ Y_UNIT_TEST_SUITE(TestFunctionSignature) {
}
};
- Y_UNIT_TEST(TestPlainFunc) {
+ Y_UNIT_TEST(TestPlainFunc) {
UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(FF)>, decltype(FF));
}
- Y_UNIT_TEST(TestMethod) {
+ Y_UNIT_TEST(TestMethod) {
UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(&A::F)>, decltype(FF));
}
- Y_UNIT_TEST(TestLambda) {
+ Y_UNIT_TEST(TestLambda) {
auto f = [](double x) -> int {
return FF(x);
};
@@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(TestFunctionSignature) {
UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(f)>, decltype(FF));
}
- Y_UNIT_TEST(TestFunction) {
+ Y_UNIT_TEST(TestFunction) {
std::function<int(double)> f(FF);
UNIT_ASSERT_TYPES_EQUAL(TFunctionSignature<decltype(f)>, decltype(FF));
@@ -51,15 +51,15 @@ Y_UNIT_TEST_SUITE(TestFunctionSignature) {
#undef FA
}
- Y_UNIT_TEST(TestTypeErasureTraits) {
+ Y_UNIT_TEST(TestTypeErasureTraits) {
TestCT<std::function<int(double, char)>>();
}
- Y_UNIT_TEST(TestPlainFunctionTraits) {
+ Y_UNIT_TEST(TestPlainFunctionTraits) {
TestCT<decltype(FFF)>();
}
- Y_UNIT_TEST(TestLambdaTraits) {
+ Y_UNIT_TEST(TestLambdaTraits) {
auto fff = [](double xx, char xxx) -> int {
return FFF(xx, xxx);
};
diff --git a/util/generic/fuzz/vector/main.cpp b/util/generic/fuzz/vector/main.cpp
index b5ad0813e3..0a0293f795 100644
--- a/util/generic/fuzz/vector/main.cpp
+++ b/util/generic/fuzz/vector/main.cpp
@@ -2,7 +2,7 @@
#include <util/stream/mem.h>
template <class T>
-static inline T Read(IInputStream& in) {
+static inline T Read(IInputStream& in) {
T t;
in.LoadOrFail(&t, sizeof(t));
diff --git a/util/generic/fwd.h b/util/generic/fwd.h
index 53766a91fa..5cc2da40e5 100644
--- a/util/generic/fwd.h
+++ b/util/generic/fwd.h
@@ -99,8 +99,8 @@ class TBitMap;
//autopointers
class TDelete;
-class TDeleteArray;
-class TFree;
+class TDeleteArray;
+class TFree;
class TCopyNew;
template <class T, class D = TDelete>
@@ -112,57 +112,57 @@ class THolder;
template <class T, class C, class D = TDelete>
class TRefCounted;
-template <class T>
-class TDefaultIntrusivePtrOps;
-
+template <class T>
+class TDefaultIntrusivePtrOps;
+
template <class T, class Ops>
-class TSimpleIntrusiveOps;
-
-template <class T, class Ops = TDefaultIntrusivePtrOps<T>>
+class TSimpleIntrusiveOps;
+
+template <class T, class Ops = TDefaultIntrusivePtrOps<T>>
class TIntrusivePtr;
-template <class T, class Ops = TDefaultIntrusivePtrOps<T>>
-class TIntrusiveConstPtr;
-
-template <class T, class Ops = TDefaultIntrusivePtrOps<T>>
-using TSimpleIntrusivePtr = TIntrusivePtr<T, TSimpleIntrusiveOps<T, Ops>>;
-
+template <class T, class Ops = TDefaultIntrusivePtrOps<T>>
+class TIntrusiveConstPtr;
+
+template <class T, class Ops = TDefaultIntrusivePtrOps<T>>
+using TSimpleIntrusivePtr = TIntrusivePtr<T, TSimpleIntrusiveOps<T, Ops>>;
+
template <class T, class C, class D = TDelete>
class TSharedPtr;
template <class T, class C = TCopyNew, class D = TDelete>
class TCopyPtr;
-template <class TPtr, class TCopy = TCopyNew>
-class TCowPtr;
-
-template <typename T>
-class TPtrArg;
-
-template <typename T>
-using TArrayHolder = THolder<T, TDeleteArray>;
-
-template <typename T>
-using TMallocHolder = THolder<T, TFree>;
-
-template <typename T>
-using TArrayPtr = TAutoPtr<T, TDeleteArray>;
-
-template <typename T>
-using TMallocPtr = TAutoPtr<T, TFree>;
-
+template <class TPtr, class TCopy = TCopyNew>
+class TCowPtr;
+
+template <typename T>
+class TPtrArg;
+
+template <typename T>
+using TArrayHolder = THolder<T, TDeleteArray>;
+
+template <typename T>
+using TMallocHolder = THolder<T, TFree>;
+
+template <typename T>
+using TArrayPtr = TAutoPtr<T, TDeleteArray>;
+
+template <typename T>
+using TMallocPtr = TAutoPtr<T, TFree>;
+
//maybe
namespace NMaybe {
struct TPolicyUndefinedExcept;
}
-
+
template <class T, class Policy = ::NMaybe::TPolicyUndefinedExcept>
class TMaybe;
-
-struct TGUID;
-
-template <class T>
-class TArrayRef;
-
-template <class T>
-using TConstArrayRef = TArrayRef<const T>;
+
+struct TGUID;
+
+template <class T>
+class TArrayRef;
+
+template <class T>
+using TConstArrayRef = TArrayRef<const T>;
diff --git a/util/generic/guid.cpp b/util/generic/guid.cpp
index c403c9b182..8b907457bc 100644
--- a/util/generic/guid.cpp
+++ b/util/generic/guid.cpp
@@ -87,7 +87,7 @@ static bool GetDigit(const char c, ui32& digit) {
return true;
}
-bool GetGuid(const TStringBuf s, TGUID& result) {
+bool GetGuid(const TStringBuf s, TGUID& result) {
size_t partId = 0;
ui64 partValue = 0;
bool isEmptyPart = true;
@@ -129,7 +129,7 @@ bool GetGuid(const TStringBuf s, TGUID& result) {
// Parses GUID from s and checks that it's valid.
// In case of error returns TGUID().
-TGUID GetGuid(const TStringBuf s) {
+TGUID GetGuid(const TStringBuf s) {
TGUID result;
if (GetGuid(s, result)) {
@@ -139,7 +139,7 @@ TGUID GetGuid(const TStringBuf s) {
return TGUID();
}
-bool GetUuid(const TStringBuf s, TGUID& result) {
+bool GetUuid(const TStringBuf s, TGUID& result) {
if (s.size() != 36) {
return false;
}
@@ -175,7 +175,7 @@ bool GetUuid(const TStringBuf s, TGUID& result) {
// Parses GUID from uuid and checks that it's valid.
// In case of error returns TGUID().
-TGUID GetUuid(const TStringBuf s) {
+TGUID GetUuid(const TStringBuf s) {
TGUID result;
if (GetUuid(s, result)) {
diff --git a/util/generic/guid.h b/util/generic/guid.h
index 7c1884d96e..2bf6c8ad99 100644
--- a/util/generic/guid.h
+++ b/util/generic/guid.h
@@ -1,7 +1,7 @@
#pragma once
-#include "fwd.h"
-
+#include "fwd.h"
+
#include <util/str_stl.h>
/**
@@ -15,13 +15,13 @@
* and https://st.yandex-team.ru/IGNIETFERRO-768 for details.
*/
struct TGUID {
- ui32 dw[4] = {};
+ ui32 dw[4] = {};
- constexpr bool IsEmpty() const noexcept {
+ constexpr bool IsEmpty() const noexcept {
return (dw[0] | dw[1] | dw[2] | dw[3]) == 0;
}
- constexpr explicit operator bool() const noexcept {
+ constexpr explicit operator bool() const noexcept {
return !IsEmpty();
}
@@ -44,23 +44,23 @@ struct TGUID {
static TGUID CreateTimebased();
};
-constexpr bool operator==(const TGUID& a, const TGUID& b) noexcept {
- return a.dw[0] == b.dw[0] && a.dw[1] == b.dw[1] && a.dw[2] == b.dw[2] && a.dw[3] == b.dw[3];
+constexpr bool operator==(const TGUID& a, const TGUID& b) noexcept {
+ return a.dw[0] == b.dw[0] && a.dw[1] == b.dw[1] && a.dw[2] == b.dw[2] && a.dw[3] == b.dw[3];
}
-constexpr bool operator!=(const TGUID& a, const TGUID& b) noexcept {
+constexpr bool operator!=(const TGUID& a, const TGUID& b) noexcept {
return !(a == b);
}
struct TGUIDHash {
- constexpr int operator()(const TGUID& a) const noexcept {
+ constexpr int operator()(const TGUID& a) const noexcept {
return a.dw[0] + a.dw[1] + a.dw[2] + a.dw[3];
}
};
template <>
struct THash<TGUID> {
- constexpr size_t operator()(const TGUID& g) const noexcept {
+ constexpr size_t operator()(const TGUID& g) const noexcept {
return (unsigned int)TGUIDHash()(g);
}
};
@@ -68,12 +68,12 @@ struct THash<TGUID> {
void CreateGuid(TGUID* res);
TString GetGuidAsString(const TGUID& g);
TString CreateGuidAsString();
-TGUID GetGuid(TStringBuf s);
-bool GetGuid(TStringBuf s, TGUID& result);
+TGUID GetGuid(TStringBuf s);
+bool GetGuid(TStringBuf s, TGUID& result);
/**
* Functions for correct parsing RFC4122 GUID, which described in
* https://en.wikipedia.org/wiki/Universally_unique_identifier
**/
-TGUID GetUuid(TStringBuf s);
-bool GetUuid(TStringBuf s, TGUID& result);
+TGUID GetUuid(TStringBuf s);
+bool GetUuid(TStringBuf s, TGUID& result);
diff --git a/util/generic/guid_ut.cpp b/util/generic/guid_ut.cpp
index b9c974b072..048354ff39 100644
--- a/util/generic/guid_ut.cpp
+++ b/util/generic/guid_ut.cpp
@@ -2,7 +2,7 @@
#include "guid.h"
-Y_UNIT_TEST_SUITE(TGuidTest) {
+Y_UNIT_TEST_SUITE(TGuidTest) {
//TODO - make real constructor
static TGUID Construct(ui32 d1, ui32 d2, ui32 d3, ui32 d4) {
TGUID ret;
@@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TGuidTest) {
TString S;
};
- Y_UNIT_TEST(Test1) {
+ Y_UNIT_TEST(Test1) {
for (size_t i = 0; i < 1000; ++i) {
TGUID g;
@@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(TGuidTest) {
}
}
- Y_UNIT_TEST(Test2) {
+ Y_UNIT_TEST(Test2) {
const TTest tests[] = {
{Construct(1, 1, 1, 1), "1-1-1-1"},
{Construct(0, 0, 0, 0), "0-0-0-0"},
@@ -60,19 +60,19 @@ Y_UNIT_TEST_SUITE(TGuidTest) {
{Construct(0, 0, 0, 0), "000000000000-000000000000000000000000000000000000000-000-0"},
};
- for (const auto& t : tests) {
+ for (const auto& t : tests) {
UNIT_ASSERT_EQUAL(t.G, GetGuid(t.S));
}
}
- Y_UNIT_TEST(Test3) {
+ Y_UNIT_TEST(Test3) {
//if this test failed, please, fix buffer size in GetGuidAsString()
TGUID max = Construct(Max<ui32>(), Max<ui32>(), Max<ui32>(), Max<ui32>());
UNIT_ASSERT_EQUAL(GetGuidAsString(max).length(), 35);
}
- Y_UNIT_TEST(Test4) {
+ Y_UNIT_TEST(Test4) {
UNIT_ASSERT_VALUES_EQUAL(GetGuidAsString(Construct(1, 2, 3, 4)), "1-2-3-4");
UNIT_ASSERT_VALUES_EQUAL(GetGuidAsString(Construct(1, 2, 0xFFFFFF, 4)), "1-2-ffffff-4");
UNIT_ASSERT_VALUES_EQUAL(GetGuidAsString(Construct(0xFAFA, 2, 3, 4)), "fafa-2-3-4");
@@ -80,7 +80,7 @@ Y_UNIT_TEST_SUITE(TGuidTest) {
UNIT_ASSERT_VALUES_EQUAL(GetGuidAsString(Construct(1, 2, 3, 0xDEAD)), "1-2-3-dead");
}
- Y_UNIT_TEST(Test5) {
+ Y_UNIT_TEST(Test5) {
const TTest tests[] = {
{TGUID(), "1-1-1-1-1"},
{TGUID(), "00000001-0001-0001-0001-00000000001-"},
diff --git a/util/generic/hash.h b/util/generic/hash.h
index 3375f61689..e46db21fa9 100644
--- a/util/generic/hash.h
+++ b/util/generic/hash.h
@@ -223,17 +223,17 @@ public:
_yhashtable_buckets(const Alloc& other)
: base_type(other)
- , Data(nullptr)
+ , Data(nullptr)
, Size()
{
}
~_yhashtable_buckets() {
- Y_ASSERT(!Data);
+ Y_ASSERT(!Data);
}
void initialize_dynamic(TBucketDivisor size) {
- Y_ASSERT(!Data);
+ Y_ASSERT(!Data);
Data = this->_get_alloc().allocate(size() + 2) + 1;
Size = size;
@@ -242,7 +242,7 @@ public:
}
void deinitialize_dynamic() {
- Y_ASSERT(Data);
+ Y_ASSERT(Data);
this->_get_alloc().deallocate(Data - 1, *reinterpret_cast<size_type*>(Data - 1));
Data = pointer();
@@ -257,7 +257,7 @@ public:
}
void deinitialize_static() {
- Y_ASSERT(Data);
+ Y_ASSERT(Data);
Data = pointer();
Size = TBucketDivisor();
@@ -500,7 +500,7 @@ private:
node* get_node() {
node* result = this->_get_alloc().allocate(1);
- Y_ASSERT((reinterpret_cast<uintptr_t>(result) & 1) == 0); /* We're using the last bit of the node pointer. */
+ Y_ASSERT((reinterpret_cast<uintptr_t>(result) & 1) == 0); /* We're using the last bit of the node pointer. */
return result;
}
void put_node(node* p) {
@@ -640,7 +640,7 @@ public:
}
iterator end() {
- return iterator(nullptr);
+ return iterator(nullptr);
} /*y*/
const_iterator begin() const {
@@ -651,7 +651,7 @@ public:
}
const_iterator end() const {
- return const_iterator(nullptr);
+ return const_iterator(nullptr);
} /*y*/
public:
@@ -767,7 +767,7 @@ public:
node* first;
for (first = buckets[n];
first && !equals(get_key(first->val), key);
- first = ((uintptr_t)first->next & 1) ? nullptr : first->next) /*y*/
+ first = ((uintptr_t)first->next & 1) ? nullptr : first->next) /*y*/
{
}
return iterator(first); /*y*/
@@ -779,7 +779,7 @@ public:
const node* first;
for (first = buckets[n];
first && !equals(get_key(first->val), key);
- first = ((uintptr_t)first->next & 1) ? nullptr : first->next) /*y*/
+ first = ((uintptr_t)first->next & 1) ? nullptr : first->next) /*y*/
{
}
return const_iterator(first); /*y*/
@@ -839,7 +839,7 @@ public:
// implemented in save_stl.h
template <class KeySaver>
- int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const;
+ int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const;
void clear(size_type downsize) {
basic_clear();
@@ -956,13 +956,13 @@ private:
template <class V>
__yhashtable_iterator<V>& __yhashtable_iterator<V>::operator++() {
- Y_ASSERT(cur);
+ Y_ASSERT(cur);
cur = cur->next;
if ((uintptr_t)cur & 1) {
node** bucket = (node**)((uintptr_t)cur & ~1);
- while (*bucket == nullptr)
+ while (*bucket == nullptr)
++bucket;
- Y_ASSERT(*bucket != nullptr);
+ Y_ASSERT(*bucket != nullptr);
cur = (node*)((uintptr_t)*bucket & ~1);
}
return *this;
@@ -977,13 +977,13 @@ inline __yhashtable_iterator<V> __yhashtable_iterator<V>::operator++(int) {
template <class V>
__yhashtable_const_iterator<V>& __yhashtable_const_iterator<V>::operator++() {
- Y_ASSERT(cur);
+ Y_ASSERT(cur);
cur = cur->next;
if ((uintptr_t)cur & 1) {
node** bucket = (node**)((uintptr_t)cur & ~1);
- while (*bucket == nullptr)
+ while (*bucket == nullptr)
++bucket;
- Y_ASSERT(*bucket != nullptr);
+ Y_ASSERT(*bucket != nullptr);
cur = (node*)((uintptr_t)*bucket & ~1);
}
return *this;
@@ -1166,7 +1166,7 @@ typename THashTable<V, K, HF, Ex, Eq, A>::size_type THashTable<V, K, HF, Ex, Eq,
}
}
if (equals(get_key(first->val), key)) {
- buckets[n] = ((uintptr_t)first->next & 1) ? nullptr : first->next; /*y*/
+ buckets[n] = ((uintptr_t)first->next & 1) ? nullptr : first->next; /*y*/
++erased;
--num_elements;
delete_node(first);
@@ -1196,7 +1196,7 @@ typename THashTable<V, K, HF, Ex, Eq, A>::size_type THashTable<V, K, HF, Ex, Eq,
}
}
if (equals(get_key(first->val), key)) {
- buckets[n] = ((uintptr_t)first->next & 1) ? nullptr : first->next; /*y*/
+ buckets[n] = ((uintptr_t)first->next & 1) ? nullptr : first->next; /*y*/
--num_elements;
delete_node(first);
return 1;
@@ -1212,7 +1212,7 @@ void THashTable<V, K, HF, Ex, Eq, A>::erase(const iterator& it) {
node* cur = buckets[n];
if (cur == p) {
- buckets[n] = ((uintptr_t)cur->next & 1) ? nullptr : cur->next; /*y*/
+ buckets[n] = ((uintptr_t)cur->next & 1) ? nullptr : cur->next; /*y*/
delete_node(cur);
--num_elements;
} else {
@@ -1280,7 +1280,7 @@ bool THashTable<V, K, HF, Ex, Eq, A>::reserve(size_type num_elements_hint) {
while (first) {
size_type new_bucket = bkt_num(first->val, n);
node* next = first->next;
- buckets[bucket] = ((uintptr_t)next & 1) ? nullptr : next; /*y*/
+ buckets[bucket] = ((uintptr_t)next & 1) ? nullptr : next; /*y*/
next = tmp[new_bucket];
first->next = next ? next : (node*)((uintptr_t) & (tmp[new_bucket + 1]) | 1); /*y*/
tmp[new_bucket] = first;
@@ -1298,7 +1298,7 @@ bool THashTable<V, K, HF, Ex, Eq, A>::reserve(size_type num_elements_hint) {
while (tmp[bucket]) {
node* next = tmp[bucket]->next;
delete_node(tmp[bucket]);
- tmp[bucket] = ((uintptr_t)next & 1) ? nullptr : next /*y*/;
+ tmp[bucket] = ((uintptr_t)next & 1) ? nullptr : next /*y*/;
}
}
throw;
@@ -1356,7 +1356,7 @@ void THashTable<V, K, HF, Ex, Eq, A>::basic_clear() {
delete_node(cur);
cur = next;
}
- *first = nullptr;
+ *first = nullptr;
}
}
num_elements = 0;
@@ -1364,7 +1364,7 @@ void THashTable<V, K, HF, Ex, Eq, A>::basic_clear() {
template <class V, class K, class HF, class Ex, class Eq, class A>
void THashTable<V, K, HF, Ex, Eq, A>::copy_from_dynamic(const THashTable& ht) {
- Y_ASSERT(buckets.size() == ht.buckets.size() && !ht.empty());
+ Y_ASSERT(buckets.size() == ht.buckets.size() && !ht.empty());
#ifdef __STL_USE_EXCEPTIONS
try {
@@ -1637,7 +1637,7 @@ public:
template <class TKey>
T& operator[](const TKey& key) {
- insert_ctx ctx = nullptr;
+ insert_ctx ctx = nullptr;
iterator it = find(key, ctx);
if (it != end()) {
@@ -1712,7 +1712,7 @@ public:
// if (stHash != NULL) bucket_count() must be equal to stHash->bucket_count()
template <class KeySaver>
- int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const {
+ int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const {
return rep.template save_for_st<KeySaver>(stream, ks, stHash);
}
@@ -1978,7 +1978,7 @@ public:
// if (stHash != NULL) bucket_count() must be equal to stHash->bucket_count()
template <class KeySaver>
- int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const {
+ int save_for_st(IOutputStream* stream, KeySaver& ks, sthash<int, int, THash<int>, TEqualTo<int>, typename KeySaver::TSizeType>* stHash = nullptr) const {
return rep.template save_for_st<KeySaver>(stream, ks, stHash);
}
diff --git a/util/generic/hash_primes_ut.cpp b/util/generic/hash_primes_ut.cpp
index 31ae562af3..7b5bf8b5c9 100644
--- a/util/generic/hash_primes_ut.cpp
+++ b/util/generic/hash_primes_ut.cpp
@@ -6,8 +6,8 @@
#include <util/string/builder.h>
#include <util/random/fast.h>
-Y_UNIT_TEST_SUITE(TestHashPrimes) {
- Y_UNIT_TEST(Test1) {
+Y_UNIT_TEST_SUITE(TestHashPrimes) {
+ Y_UNIT_TEST(Test1) {
UNIT_ASSERT_VALUES_EQUAL(HashBucketCount(1), 7);
UNIT_ASSERT_VALUES_EQUAL(HashBucketCount(6), 7);
UNIT_ASSERT_VALUES_EQUAL(HashBucketCount(7), 7);
diff --git a/util/generic/hash_set.h b/util/generic/hash_set.h
index 8da03fd597..e8088cf23b 100644
--- a/util/generic/hash_set.h
+++ b/util/generic/hash_set.h
@@ -241,7 +241,7 @@ public:
}
template <class KeySaver>
- int save_for_st(IOutputStream* stream, KeySaver& ks) const {
+ int save_for_st(IOutputStream* stream, KeySaver& ks) const {
return rep.template save_for_st<KeySaver>(stream, ks);
}
diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp
index 060d617650..0551d58770 100644
--- a/util/generic/hash_ut.cpp
+++ b/util/generic/hash_ut.cpp
@@ -57,7 +57,7 @@ class THashTest: public TTestBase {
UNIT_TEST(TestHMMapInitializerList);
UNIT_TEST(TestHSetInitializerList);
UNIT_TEST(TestHMSetInitializerList);
- UNIT_TEST(TestHSetInsertInitializerList);
+ UNIT_TEST(TestHSetInsertInitializerList);
UNIT_TEST(TestTupleHash);
UNIT_TEST_SUITE_END();
@@ -108,7 +108,7 @@ protected:
void TestHMMapInitializerList();
void TestHSetInitializerList();
void TestHMSetInitializerList();
- void TestHSetInsertInitializerList();
+ void TestHSetInsertInitializerList();
void TestTupleHash();
};
@@ -798,7 +798,7 @@ public:
TCountingAllocator(TAllocatorCounters* counters)
: Counters_(counters)
{
- Y_ASSERT(counters);
+ Y_ASSERT(counters);
}
template <class Other>
@@ -1187,44 +1187,44 @@ void THashTest::TestHMSetInitializerList() {
h2.insert("baz");
UNIT_ASSERT_EQUAL(h1, h2);
}
-
-namespace {
- struct TFoo {
- int A;
- int B;
-
+
+namespace {
+ struct TFoo {
+ int A;
+ int B;
+
bool operator==(const TFoo& o) const {
- return A == o.A && B == o.B;
- }
- };
-}
-
-template <>
-struct THash<TFoo> {
- size_t operator()(const TFoo& v) const {
- return v.A ^ v.B;
- }
-};
-
-template <>
-void Out<TFoo>(IOutputStream& o, const TFoo& v) {
- o << '{' << v.A << ';' << v.B << '}';
-}
-
-void THashTest::TestHSetInsertInitializerList() {
- {
+ return A == o.A && B == o.B;
+ }
+ };
+}
+
+template <>
+struct THash<TFoo> {
+ size_t operator()(const TFoo& v) const {
+ return v.A ^ v.B;
+ }
+};
+
+template <>
+void Out<TFoo>(IOutputStream& o, const TFoo& v) {
+ o << '{' << v.A << ';' << v.B << '}';
+}
+
+void THashTest::TestHSetInsertInitializerList() {
+ {
const THashSet<int> x = {1};
THashSet<int> y;
- y.insert({1});
- UNIT_ASSERT_VALUES_EQUAL(x, y);
- }
- {
+ y.insert({1});
+ UNIT_ASSERT_VALUES_EQUAL(x, y);
+ }
+ {
const THashSet<int> x = {1, 2};
THashSet<int> y;
- y.insert({1, 2});
- UNIT_ASSERT_VALUES_EQUAL(x, y);
- }
- {
+ y.insert({1, 2});
+ UNIT_ASSERT_VALUES_EQUAL(x, y);
+ }
+ {
const THashSet<int> x = {1, 2, 3, 4, 5};
THashSet<int> y;
y.insert({
@@ -1234,21 +1234,21 @@ void THashTest::TestHSetInsertInitializerList() {
4,
5,
});
- UNIT_ASSERT_VALUES_EQUAL(x, y);
- }
- {
+ UNIT_ASSERT_VALUES_EQUAL(x, y);
+ }
+ {
const THashSet<TFoo> x = {{1, 2}};
THashSet<TFoo> y;
- y.insert({{1, 2}});
- UNIT_ASSERT_VALUES_EQUAL(x, y);
- }
- {
+ y.insert({{1, 2}});
+ UNIT_ASSERT_VALUES_EQUAL(x, y);
+ }
+ {
const THashSet<TFoo> x = {{1, 2}, {3, 4}};
THashSet<TFoo> y;
- y.insert({{1, 2}, {3, 4}});
- UNIT_ASSERT_VALUES_EQUAL(x, y);
- }
-}
+ y.insert({{1, 2}, {3, 4}});
+ UNIT_ASSERT_VALUES_EQUAL(x, y);
+ }
+}
/*
* Sequence for MultiHash is reversed as it calculates hash as
diff --git a/util/generic/intrlist.h b/util/generic/intrlist.h
index 93112c37f7..b5d3f2051b 100644
--- a/util/generic/intrlist.h
+++ b/util/generic/intrlist.h
@@ -332,11 +332,11 @@ public:
TIntrusiveList temp;
temp.Append(right);
- Y_ASSERT(right.Empty());
+ Y_ASSERT(right.Empty());
right.Append(*this);
- Y_ASSERT(this->Empty());
+ Y_ASSERT(this->Empty());
this->Append(temp);
- Y_ASSERT(temp.Empty());
+ Y_ASSERT(temp.Empty());
}
public:
@@ -823,12 +823,12 @@ public:
}
inline T* Front() noexcept {
- Y_ASSERT(Begin_);
+ Y_ASSERT(Begin_);
return Begin_->Node();
}
inline const T* Front() const noexcept {
- Y_ASSERT(Begin_);
+ Y_ASSERT(Begin_);
return Begin_->Node();
}
@@ -838,7 +838,7 @@ public:
}
inline T* PopFront() noexcept {
- Y_ASSERT(Begin_);
+ Y_ASSERT(Begin_);
TListItem* const ret = Begin_;
Begin_ = Begin_->Next();
diff --git a/util/generic/intrlist_ut.cpp b/util/generic/intrlist_ut.cpp
index 96a7b19e07..eff7cdf2ee 100644
--- a/util/generic/intrlist_ut.cpp
+++ b/util/generic/intrlist_ut.cpp
@@ -2,7 +2,7 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
class TListTest: public TTestBase {
UNIT_TEST_SUITE(TListTest);
diff --git a/util/generic/is_in.h b/util/generic/is_in.h
index acfd5ec350..4f175ea5eb 100644
--- a/util/generic/is_in.h
+++ b/util/generic/is_in.h
@@ -12,9 +12,9 @@ template <class C, class T>
static inline bool IsIn(const C& c, const T& e);
namespace NIsInHelper {
- Y_HAS_MEMBER(find, FindMethod);
- Y_HAS_SUBTYPE(const_iterator, ConstIterator);
- Y_HAS_SUBTYPE(key_type, KeyType);
+ Y_HAS_MEMBER(find, FindMethod);
+ Y_HAS_SUBTYPE(const_iterator, ConstIterator);
+ Y_HAS_SUBTYPE(key_type, KeyType);
template <class T>
using TIsAssocCont = TConjunction<THasFindMethod<T>, THasConstIterator<T>, THasKeyType<T>>;
@@ -44,7 +44,7 @@ static inline bool IsIn(I f, I l, const T& v) {
template <class C, class T>
static inline bool IsIn(const C& c, const T& e) {
using namespace NIsInHelper;
- return TIsInTraits<C, T, TIsAssocCont<C>::value>::IsIn(c, e);
+ return TIsInTraits<C, T, TIsAssocCont<C>::value>::IsIn(c, e);
}
template <class T, class U>
diff --git a/util/generic/is_in_ut.cpp b/util/generic/is_in_ut.cpp
index b60f7a8239..c668bce807 100644
--- a/util/generic/is_in_ut.cpp
+++ b/util/generic/is_in_ut.cpp
@@ -9,7 +9,7 @@
#include "strbuf.h"
#include "string.h"
-Y_UNIT_TEST_SUITE(TIsIn) {
+Y_UNIT_TEST_SUITE(TIsIn) {
template <class TCont, class T>
void TestIsInWithCont(const T& elem) {
class TMapMock: public TCont {
@@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TIsIn) {
m.FindCalled = 0;
}
- Y_UNIT_TEST(IsInTest) {
+ Y_UNIT_TEST(IsInTest) {
TestIsInWithCont<TMap<TString, TString>>(std::make_pair("found", "1"));
TestIsInWithCont<TMultiMap<TString, TString>>(std::make_pair("found", "1"));
TestIsInWithCont<THashMap<TString, TString>>(std::make_pair("found", "1"));
@@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TIsIn) {
UNIT_ASSERT(!IsIn(b, 'z'));
}
- Y_UNIT_TEST(IsInInitListTest) {
+ Y_UNIT_TEST(IsInInitListTest) {
const char* abc = "abc";
const char* def = "def";
@@ -94,9 +94,9 @@ Y_UNIT_TEST_SUITE(TIsIn) {
UNIT_ASSERT(IsIn({"abc", "def"}, TStringBuf{str.data(), 3}));
}
- Y_UNIT_TEST(ConfOfTest) {
- UNIT_ASSERT(IsIn({1, 2, 3}, 1));
- UNIT_ASSERT(!IsIn({1, 2, 3}, 4));
+ Y_UNIT_TEST(ConfOfTest) {
+ UNIT_ASSERT(IsIn({1, 2, 3}, 1));
+ UNIT_ASSERT(!IsIn({1, 2, 3}, 4));
const TString b = "b";
diff --git a/util/generic/iterator.h b/util/generic/iterator.h
index 21fa5d781d..19e9d20976 100644
--- a/util/generic/iterator.h
+++ b/util/generic/iterator.h
@@ -1,6 +1,6 @@
#pragma once
-#include <iterator>
+#include <iterator>
#include <utility>
namespace NStlIterator {
@@ -130,10 +130,10 @@ public:
/**
* Transform given reverse iterator into forward iterator pointing to the same element.
- *
+ *
* @see http://stackoverflow.com/a/1830240
- */
+ */
template <class TIterator>
auto ToForwardIterator(TIterator iter) {
- return std::next(iter).base();
+ return std::next(iter).base();
}
diff --git a/util/generic/iterator_range_ut.cpp b/util/generic/iterator_range_ut.cpp
index fa6cb3c0ad..a7e3670ae1 100644
--- a/util/generic/iterator_range_ut.cpp
+++ b/util/generic/iterator_range_ut.cpp
@@ -4,8 +4,8 @@
#include <util/generic/algorithm.h>
#include <util/generic/vector.h>
-Y_UNIT_TEST_SUITE(IteratorRange) {
- Y_UNIT_TEST(DefaultConstructor) {
+Y_UNIT_TEST_SUITE(IteratorRange) {
+ Y_UNIT_TEST(DefaultConstructor) {
TIteratorRange<int*> range;
UNIT_ASSERT(range.empty());
}
@@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(IteratorRange) {
UNIT_ASSERT(range.empty());
}
- Y_UNIT_TEST(RangeBasedForLoop) {
+ Y_UNIT_TEST(RangeBasedForLoop) {
// compileability test
for (int i : TIteratorRange<int*>()) {
Y_UNUSED(i);
@@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(IteratorRange) {
}
}
- Y_UNIT_TEST(Works) {
+ Y_UNIT_TEST(Works) {
const int values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
auto range = MakeIteratorRange(values, values + Y_ARRAY_SIZE(values));
UNIT_ASSERT_VALUES_EQUAL(range.size(), Y_ARRAY_SIZE(values));
@@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(IteratorRange) {
UNIT_ASSERT_VALUES_EQUAL(i, 10);
}
- Y_UNIT_TEST(OperatorsAndReferences) {
+ Y_UNIT_TEST(OperatorsAndReferences) {
TVector<size_t> values{1, 2, 3, 4, 5};
auto range = MakeIteratorRange(values.begin(), values.end());
UNIT_ASSERT_VALUES_EQUAL(range[2], 3);
@@ -88,7 +88,7 @@ Y_UNIT_TEST_SUITE(IteratorRange) {
UNIT_ASSERT_VALUES_EQUAL(rangeBVector[6], false);
}
- Y_UNIT_TEST(CanUseInAlgorithms) {
+ Y_UNIT_TEST(CanUseInAlgorithms) {
const int values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
auto range = MakeIteratorRange(values, values + Y_ARRAY_SIZE(values));
// more like compileability test
diff --git a/util/generic/iterator_ut.cpp b/util/generic/iterator_ut.cpp
index 068dcb5f9b..00be19e10e 100644
--- a/util/generic/iterator_ut.cpp
+++ b/util/generic/iterator_ut.cpp
@@ -2,11 +2,11 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TIterator) {
- Y_UNIT_TEST(ToForwardIteratorTest) {
+Y_UNIT_TEST_SUITE(TIterator) {
+ Y_UNIT_TEST(ToForwardIteratorTest) {
TVector<int> x = {1, 2};
- UNIT_ASSERT_VALUES_EQUAL(*std::prev(x.end()), *ToForwardIterator(x.rbegin()));
- UNIT_ASSERT_VALUES_EQUAL(*ToForwardIterator(std::prev(x.rend())), *x.begin());
+ UNIT_ASSERT_VALUES_EQUAL(*std::prev(x.end()), *ToForwardIterator(x.rbegin()));
+ UNIT_ASSERT_VALUES_EQUAL(*ToForwardIterator(std::prev(x.rend())), *x.begin());
}
}
diff --git a/util/generic/lazy_value.h b/util/generic/lazy_value.h
index 49aa46bee3..3c720f76b5 100644
--- a/util/generic/lazy_value.h
+++ b/util/generic/lazy_value.h
@@ -39,7 +39,7 @@ public:
}
void InitDefault() const {
- Y_ASSERT(Initializer);
+ Y_ASSERT(Initializer);
ValueHolder = Initializer();
}
diff --git a/util/generic/lazy_value_ut.cpp b/util/generic/lazy_value_ut.cpp
index 8d9cb49673..f6135880c3 100644
--- a/util/generic/lazy_value_ut.cpp
+++ b/util/generic/lazy_value_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TLazyValueTestSuite) {
- Y_UNIT_TEST(TestLazyValue) {
+Y_UNIT_TEST_SUITE(TLazyValueTestSuite) {
+ Y_UNIT_TEST(TestLazyValue) {
TLazyValue<int> value([]() {
return 5;
});
@@ -12,7 +12,7 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) {
UNIT_ASSERT(value);
}
- Y_UNIT_TEST(TestLazyValueInitialization) {
+ Y_UNIT_TEST(TestLazyValueInitialization) {
TLazyValue<int> value1([]() { return 5; });
TLazyValue<int> value2 = []() { return 5; };
@@ -24,7 +24,7 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) {
copy1 = value2;
}
- Y_UNIT_TEST(TestLazyValueCopy) {
+ Y_UNIT_TEST(TestLazyValueCopy) {
TLazyValue<int> value([]() { return 5; });
UNIT_ASSERT(!value);
@@ -113,13 +113,13 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) {
size_t TValueProvider::CountParseDataCalled = 0;
- Y_UNIT_TEST(TestValueProvider) {
+ Y_UNIT_TEST(TestValueProvider) {
TValueProvider provider;
UNIT_ASSERT(provider.GetData() == "hi");
}
- Y_UNIT_TEST(TestValueProviderCopy) {
+ Y_UNIT_TEST(TestValueProviderCopy) {
TValueProvider provider;
provider.GetData();
const auto countParsed = TValueProvider::CountParseDataCalled;
@@ -132,7 +132,7 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) {
UNIT_ASSERT_EQUAL(countParsed, TValueProvider::CountParseDataCalled);
}
- Y_UNIT_TEST(TestEmptyProviderCopy) {
+ Y_UNIT_TEST(TestEmptyProviderCopy) {
TValueProvider provider;
TValueProvider copy(provider);
@@ -146,7 +146,7 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) {
UNIT_ASSERT_EQUAL(countParsed + 2, TValueProvider::CountParseDataCalled);
}
- Y_UNIT_TEST(TestMakeLazy) {
+ Y_UNIT_TEST(TestMakeLazy) {
auto lv = MakeLazy([] {
return 100500;
});
diff --git a/util/generic/list_ut.cpp b/util/generic/list_ut.cpp
index 3d97b66b60..9e60ecf01b 100644
--- a/util/generic/list_ut.cpp
+++ b/util/generic/list_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TYListSuite) {
- Y_UNIT_TEST(TestInitializerList) {
+Y_UNIT_TEST_SUITE(TYListSuite) {
+ Y_UNIT_TEST(TestInitializerList) {
TList<int> l = {3, 42, 6};
TList<int> expected;
expected.push_back(3);
diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp
index 5f6acd181f..79e832b024 100644
--- a/util/generic/map_ut.cpp
+++ b/util/generic/map_ut.cpp
@@ -4,14 +4,14 @@
#include <util/memory/pool.h>
#include <algorithm>
-Y_UNIT_TEST_SUITE(TYMapTest) {
+Y_UNIT_TEST_SUITE(TYMapTest) {
template <typename TAlloc>
void DoTestMap1(TMap<char, int, TLess<char>, TAlloc>& m);
template <typename TAlloc>
void DoTestMMap1(TMultiMap<char, int, TLess<char>, TAlloc>& mm);
- Y_UNIT_TEST(TestMap1) {
+ Y_UNIT_TEST(TestMap1) {
{
TMap<char, int, TLess<char>> m;
DoTestMap1(m);
@@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
}
}
- Y_UNIT_TEST(TestMMap1) {
+ Y_UNIT_TEST(TestMMap1) {
{
TMultiMap<char, int, TLess<char>> mm;
DoTestMMap1(mm);
@@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
UNIT_ASSERT(count == 2);
}
- Y_UNIT_TEST(TestMMap2) {
+ Y_UNIT_TEST(TestMMap2) {
using pair_type = std::pair<const int, char>;
pair_type p1(3, 'c');
@@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
UNIT_ASSERT((*i).second == 'f');
}
- Y_UNIT_TEST(TestIterators) {
+ Y_UNIT_TEST(TestIterators) {
using int_map = TMap<int, char, TLess<int>>;
int_map imap;
@@ -187,7 +187,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
UNIT_ASSERT((*rci).second == 'f');
}
- Y_UNIT_TEST(TestEqualRange) {
+ Y_UNIT_TEST(TestEqualRange) {
using maptype = TMap<char, int, TLess<char>>;
{
@@ -274,7 +274,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
using is_transparent = void;
};
- Y_UNIT_TEST(TestTemplateMethods) {
+ Y_UNIT_TEST(TestTemplateMethods) {
{
using Container = TMap<TKey, int, TKeyCmp>;
using value = Container::value_type;
@@ -398,7 +398,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
UNIT_ASSERT(c);
}
- Y_UNIT_TEST(TestEmpty) {
+ Y_UNIT_TEST(TestEmpty) {
EmptyAndInsertTest<TMap<char, int, TLess<char>>>(std::pair<char, int>('a', 1));
EmptyAndInsertTest<TMultiMap<char, int, TLess<char>>>(std::pair<char, int>('a', 1));
}
@@ -420,7 +420,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
}
};
- Y_UNIT_TEST(TestMoveComparator) {
+ Y_UNIT_TEST(TestMoveComparator) {
using Container = TMultiMap<TKey, int, TParametrizedKeyCmp>;
TParametrizedKeyCmp direct(false);
@@ -435,8 +435,8 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
c.insert(std::make_pair(TKey(3), 103));
TVector<int> values;
- for (auto& i : c) {
- values.push_back(i.second);
+ for (auto& i : c) {
+ values.push_back(i.second);
}
UNIT_ASSERT_VALUES_EQUAL(values.size(), 3);
@@ -446,7 +446,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
}
}
- Y_UNIT_TEST(TestMapInitializerList) {
+ Y_UNIT_TEST(TestMapInitializerList) {
TMap<TString, int> m = {
{"one", 1},
{"two", 2},
@@ -461,7 +461,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
UNIT_ASSERT_VALUES_EQUAL(m["four"], 4);
}
- Y_UNIT_TEST(TestMMapInitializerList) {
+ Y_UNIT_TEST(TestMMapInitializerList) {
TMultiMap<TString, int> mm = {
{"one", 1},
{"two", 2},
@@ -477,7 +477,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
UNIT_ASSERT_VALUES_EQUAL(mm, expected);
}
- Y_UNIT_TEST(TestMovePoolAlloc) {
+ Y_UNIT_TEST(TestMovePoolAlloc) {
using TMapInPool = TMap<int, int, TLess<int>, TPoolAllocator>;
TMemoryPool pool(1);
diff --git a/util/generic/mapfindptr.h b/util/generic/mapfindptr.h
index e7d1b31000..bc10cac60f 100644
--- a/util/generic/mapfindptr.h
+++ b/util/generic/mapfindptr.h
@@ -14,14 +14,14 @@ template <class Map, class K>
inline auto MapFindPtr(Map& map, const K& key) {
auto i = map.find(key);
- return (i == map.end() ? nullptr : &i->second);
+ return (i == map.end() ? nullptr : &i->second);
}
template <class Map, class K>
inline auto MapFindPtr(const Map& map, const K& key) {
auto i = map.find(key);
- return (i == map.end() ? nullptr : &i->second);
+ return (i == map.end() ? nullptr : &i->second);
}
/** helper for THashMap/TMap */
diff --git a/util/generic/mapfindptr_ut.cpp b/util/generic/mapfindptr_ut.cpp
index 10ed7992fe..613da7a96b 100644
--- a/util/generic/mapfindptr_ut.cpp
+++ b/util/generic/mapfindptr_ut.cpp
@@ -7,16 +7,16 @@
#include "mapfindptr.h"
-Y_UNIT_TEST_SUITE(TMapFindPtrTest) {
+Y_UNIT_TEST_SUITE(TMapFindPtrTest) {
struct TTestMap: std::map<int, TString>, TMapOps<TTestMap> {};
- Y_UNIT_TEST(TestDerivedClass) {
+ Y_UNIT_TEST(TestDerivedClass) {
TTestMap a;
a[42] = "cat";
UNIT_ASSERT(a.FindPtr(42));
UNIT_ASSERT_EQUAL(*a.FindPtr(42), "cat");
- UNIT_ASSERT_EQUAL(a.FindPtr(0), nullptr);
+ UNIT_ASSERT_EQUAL(a.FindPtr(0), nullptr);
//test mutation
if (TString* p = a.FindPtr(42)) {
@@ -28,13 +28,13 @@ Y_UNIT_TEST_SUITE(TMapFindPtrTest) {
//test const-overloaded functions too
const TTestMap& b = a;
UNIT_ASSERT(b.FindPtr(42) && *b.FindPtr(42) == "dog");
- UNIT_ASSERT_EQUAL(b.FindPtr(0), nullptr);
+ UNIT_ASSERT_EQUAL(b.FindPtr(0), nullptr);
UNIT_ASSERT_STRINGS_EQUAL(b.Value(42, "cat"), "dog");
UNIT_ASSERT_STRINGS_EQUAL(b.Value(0, "alien"), "alien");
}
- Y_UNIT_TEST(TestTemplateFind) {
+ Y_UNIT_TEST(TestTemplateFind) {
THashMap<TString, int> m;
m[TString("x")] = 2;
@@ -43,7 +43,7 @@ Y_UNIT_TEST_SUITE(TMapFindPtrTest) {
UNIT_ASSERT_EQUAL(*m.FindPtr(TStringBuf("x")), 2);
}
- Y_UNIT_TEST(TestValue) {
+ Y_UNIT_TEST(TestValue) {
TTestMap a;
a[1] = "lol";
@@ -52,7 +52,7 @@ Y_UNIT_TEST_SUITE(TMapFindPtrTest) {
UNIT_ASSERT_VALUES_EQUAL(a.Value(2, "123"), "123");
}
- Y_UNIT_TEST(TestValueRef) {
+ Y_UNIT_TEST(TestValueRef) {
TTestMap a;
a[1] = "lol";
diff --git a/util/generic/maybe.h b/util/generic/maybe.h
index 63427876da..34d21aebcd 100644
--- a/util/generic/maybe.h
+++ b/util/generic/maybe.h
@@ -6,7 +6,7 @@
#include "yexception.h"
#include <util/system/align.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/ysaveload.h>
namespace NMaybe {
@@ -386,7 +386,7 @@ public:
return Defined();
}
- void Save(IOutputStream* out) const {
+ void Save(IOutputStream* out) const {
const bool defined = Defined();
::Save<bool>(out, defined);
@@ -396,7 +396,7 @@ public:
}
}
- void Load(IInputStream* in) {
+ void Load(IInputStream* in) {
bool defined;
::Load(in, defined);
@@ -709,7 +709,7 @@ constexpr bool operator>=(const U& value, const TMaybe<T, TPolicy>& maybe) {
return !(value < maybe);
}
-class IOutputStream;
+class IOutputStream;
template <class T, class TPolicy>
inline IOutputStream& operator<<(IOutputStream& out, const TMaybe<T, TPolicy>& maybe) {
diff --git a/util/generic/maybe_ut.cpp b/util/generic/maybe_ut.cpp
index c30e9d9602..2c1a425c5e 100644
--- a/util/generic/maybe_ut.cpp
+++ b/util/generic/maybe_ut.cpp
@@ -20,7 +20,7 @@ public:
}
};
-Y_UNIT_TEST_SUITE(TMaybeTest) {
+Y_UNIT_TEST_SUITE(TMaybeTest) {
Y_UNIT_TEST(TestStatic) {
using T1 = TMaybe<int>;
static_assert(std::is_trivially_copy_constructible<T1>::value, "");
@@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
static_assert(!std::is_trivially_destructible<T4>::value, "");
}
- Y_UNIT_TEST(TestWarning) {
+ Y_UNIT_TEST(TestWarning) {
TMaybe<size_t> x;
TStringStream ss;
TString line;
@@ -53,7 +53,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TTestConstructorDestructor) {
+ Y_UNIT_TEST(TTestConstructorDestructor) {
int a = 0;
int b = 0;
@@ -98,7 +98,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TestAssignmentClear) {
+ Y_UNIT_TEST(TestAssignmentClear) {
TMaybe<int> m5;
UNIT_ASSERT(!m5.Defined());
UNIT_ASSERT(m5.Empty());
@@ -141,7 +141,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(m5.Empty());
}
- Y_UNIT_TEST(TestInPlace) {
+ Y_UNIT_TEST(TestInPlace) {
TMaybe<int> m;
UNIT_ASSERT(!m);
@@ -157,7 +157,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(m == 7);
}
- Y_UNIT_TEST(TestMove) {
+ Y_UNIT_TEST(TestMove) {
struct TMovable {
int Flag = 0;
@@ -209,7 +209,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT_VALUES_EQUAL(o6.Flag, 6);
}
- Y_UNIT_TEST(TestCast) {
+ Y_UNIT_TEST(TestCast) {
// Undefined maybe casts to undefined maybe
TMaybe<short> shortMaybe;
const auto undefinedMaybe = shortMaybe.Cast<long>();
@@ -222,7 +222,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT_VALUES_EQUAL(34, longMaybe.GetRef());
}
- Y_UNIT_TEST(TestGetOr) {
+ Y_UNIT_TEST(TestGetOr) {
UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>().GetOrElse("xxx"), TString("xxx"));
UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>("yyy").GetOrElse("xxx"), TString("yyy"));
@@ -248,7 +248,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
>=
*/
- Y_UNIT_TEST(TestCompareEqualEmpty) {
+ Y_UNIT_TEST(TestCompareEqualEmpty) {
TMaybe<int> m1;
TMaybe<int> m2;
@@ -260,7 +260,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(m1 >= m2);
}
- Y_UNIT_TEST(TestCompareEqualNonEmpty) {
+ Y_UNIT_TEST(TestCompareEqualNonEmpty) {
TMaybe<int> m1{1};
TMaybe<int> m2{1};
@@ -272,7 +272,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(m1 >= m2);
}
- Y_UNIT_TEST(TestCompareOneLessThanOther) {
+ Y_UNIT_TEST(TestCompareOneLessThanOther) {
TMaybe<int> m1{1};
TMaybe<int> m2{2};
@@ -284,7 +284,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(!(m1 >= m2));
}
- Y_UNIT_TEST(TestCompareTMaybeAndT_Equal) {
+ Y_UNIT_TEST(TestCompareTMaybeAndT_Equal) {
TMaybe<int> m{1};
int v{1};
@@ -303,7 +303,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(v >= m);
}
- Y_UNIT_TEST(TestCompareTMaybeAndT_TMaybeLessThanT) {
+ Y_UNIT_TEST(TestCompareTMaybeAndT_TMaybeLessThanT) {
TMaybe<int> m{1};
int v{2};
@@ -322,7 +322,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(v >= m);
}
- Y_UNIT_TEST(TestCompareTMaybeAndT_TMaybeGreaterThanT) {
+ Y_UNIT_TEST(TestCompareTMaybeAndT_TMaybeGreaterThanT) {
TMaybe<int> m{2};
int v{1};
@@ -341,7 +341,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(!(v >= m));
}
- Y_UNIT_TEST(TestCompareEmptyTMaybeAndT) {
+ Y_UNIT_TEST(TestCompareEmptyTMaybeAndT) {
TMaybe<int> m;
int v{1};
@@ -360,7 +360,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(v >= m);
}
- Y_UNIT_TEST(TestCompareEmptyTMaybeAndNothing) {
+ Y_UNIT_TEST(TestCompareEmptyTMaybeAndNothing) {
TMaybe<int> m;
auto n = Nothing();
@@ -379,7 +379,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(n >= m);
}
- Y_UNIT_TEST(TestCompareNonEmptyTMaybeAndNothing) {
+ Y_UNIT_TEST(TestCompareNonEmptyTMaybeAndNothing) {
TMaybe<int> m{1};
auto n = Nothing();
@@ -398,7 +398,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(!(n >= m));
}
- Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_Equal) {
+ Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_Equal) {
TMaybe<size_t> m{1};
unsigned int v{1};
@@ -417,7 +417,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(v >= m);
}
- Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_TMaybeLessThanT) {
+ Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_TMaybeLessThanT) {
TMaybe<size_t> m{1};
unsigned int v{2};
@@ -436,7 +436,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(v >= m);
}
- Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_TMaybeGreaterThanT) {
+ Y_UNIT_TEST(TestCompareTMaybeAndConvertibleT_TMaybeGreaterThanT) {
TMaybe<size_t> m{2};
unsigned int v{1};
@@ -455,7 +455,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(!(v >= m));
}
- Y_UNIT_TEST(TestCompareEmptyTMaybeAndConvertibleT) {
+ Y_UNIT_TEST(TestCompareEmptyTMaybeAndConvertibleT) {
TMaybe<size_t> m;
unsigned int v{1};
@@ -474,7 +474,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(v >= m);
}
- Y_UNIT_TEST(TestMakeMaybe) {
+ Y_UNIT_TEST(TestMakeMaybe) {
{
auto m1 = MakeMaybe<int>(1);
UNIT_ASSERT(*m1 == 1);
@@ -583,7 +583,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TestSwappingUsingMemberSwap) {
+ Y_UNIT_TEST(TestSwappingUsingMemberSwap) {
{
TMaybe<int> m1 = 1;
TMaybe<int> m2 = 2;
@@ -624,7 +624,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TestSwappingUsingMemberLittleSwap) {
+ Y_UNIT_TEST(TestSwappingUsingMemberLittleSwap) {
{
TMaybe<int> m1 = 1;
TMaybe<int> m2 = 2;
@@ -665,7 +665,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TestSwappingUsingGlobalSwap) {
+ Y_UNIT_TEST(TestSwappingUsingGlobalSwap) {
{
TMaybe<int> m1 = 1;
TMaybe<int> m2 = 2;
@@ -706,7 +706,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TestSwappingUsingGlobalDoSwap) {
+ Y_UNIT_TEST(TestSwappingUsingGlobalDoSwap) {
{
TMaybe<int> m1 = 1;
TMaybe<int> m2 = 2;
@@ -747,7 +747,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TestSwappingUsingStdSwap) {
+ Y_UNIT_TEST(TestSwappingUsingStdSwap) {
{
TMaybe<int> m1 = 1;
TMaybe<int> m2 = 2;
@@ -788,28 +788,28 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
}
}
- Y_UNIT_TEST(TestOutputStreamEmptyMaybe) {
+ Y_UNIT_TEST(TestOutputStreamEmptyMaybe) {
TString s;
TStringOutput output(s);
output << TMaybe<int>();
UNIT_ASSERT_EQUAL("(empty maybe)", s);
}
- Y_UNIT_TEST(TestOutputStreamNothing) {
+ Y_UNIT_TEST(TestOutputStreamNothing) {
TString s;
TStringOutput output(s);
output << Nothing();
UNIT_ASSERT_VALUES_EQUAL("(empty maybe)", s);
}
- Y_UNIT_TEST(TestOutputStreamDefinedMaybe) {
+ Y_UNIT_TEST(TestOutputStreamDefinedMaybe) {
TString s;
TStringOutput output(s);
output << TMaybe<int>(42);
UNIT_ASSERT_EQUAL("42", s);
}
- Y_UNIT_TEST(TestMaybeCovarianceImplicit) {
+ Y_UNIT_TEST(TestMaybeCovarianceImplicit) {
struct TestStruct {
TestStruct(int value)
: Value_(value)
@@ -835,7 +835,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(!testMaybeEmpty.Defined());
}
- Y_UNIT_TEST(TestMaybeCovarianceExplicit) {
+ Y_UNIT_TEST(TestMaybeCovarianceExplicit) {
struct TestStruct {
explicit TestStruct(int value)
: Value_(value)
@@ -853,7 +853,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(!testStructMaybeEmpty.Defined());
}
- Y_UNIT_TEST(TestMaybeCovarianceAssign) {
+ Y_UNIT_TEST(TestMaybeCovarianceAssign) {
struct TestStruct {
explicit TestStruct(int value)
: Value_(value)
@@ -881,7 +881,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(!testStructMaybe.Defined());
}
- Y_UNIT_TEST(TestMaybeCovarianceNonTrivial) {
+ Y_UNIT_TEST(TestMaybeCovarianceNonTrivial) {
struct TestStruct {
enum {
FromValue,
@@ -918,7 +918,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT_EQUAL(testStructFromValue.GetRef().Value_, 23);
}
- Y_UNIT_TEST(TestMaybeCovarianceNonTrivialAssign) {
+ Y_UNIT_TEST(TestMaybeCovarianceNonTrivialAssign) {
struct TestStruct {
enum {
FromValue,
diff --git a/util/generic/mem_copy.h b/util/generic/mem_copy.h
index ad6c253143..b68c852953 100644
--- a/util/generic/mem_copy.h
+++ b/util/generic/mem_copy.h
@@ -7,10 +7,10 @@
#include <cstring>
template <class T>
-using TIfPOD = std::enable_if_t<TTypeTraits<T>::IsPod, T*>;
+using TIfPOD = std::enable_if_t<TTypeTraits<T>::IsPod, T*>;
template <class T>
-using TIfNotPOD = std::enable_if_t<!TTypeTraits<T>::IsPod, T*>;
+using TIfNotPOD = std::enable_if_t<!TTypeTraits<T>::IsPod, T*>;
template <class T>
static inline TIfPOD<T> MemCopy(T* to, const T* from, size_t n) noexcept {
diff --git a/util/generic/mem_copy_ut.cpp b/util/generic/mem_copy_ut.cpp
index 891827b721..8b55a11cf6 100644
--- a/util/generic/mem_copy_ut.cpp
+++ b/util/generic/mem_copy_ut.cpp
@@ -18,10 +18,10 @@ namespace {
};
}
-Y_DECLARE_PODTYPE(TB);
+Y_DECLARE_PODTYPE(TB);
-Y_UNIT_TEST_SUITE(TestMemCopy) {
- Y_UNIT_TEST(Test1) {
+Y_UNIT_TEST_SUITE(TestMemCopy) {
+ Y_UNIT_TEST(Test1) {
char buf[] = "123";
char buf1[sizeof(buf)];
@@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TestMemCopy) {
int X;
};
- Y_UNIT_TEST(Test2) {
+ Y_UNIT_TEST(Test2) {
x = 0;
TA a1[5];
@@ -58,14 +58,14 @@ Y_UNIT_TEST_SUITE(TestMemCopy) {
}
}
- Y_UNIT_TEST(Test3) {
+ Y_UNIT_TEST(Test3) {
TB b1[5];
TB b2[5];
MemCopy(b2, b1, 5);
}
- Y_UNIT_TEST(Test4) {
+ Y_UNIT_TEST(Test4) {
TC c1[5];
TC c2[5];
@@ -81,7 +81,7 @@ Y_UNIT_TEST_SUITE(TestMemCopy) {
}
}
- Y_UNIT_TEST(Test5) {
+ Y_UNIT_TEST(Test5) {
struct TD {
int X;
};
@@ -104,7 +104,7 @@ Y_UNIT_TEST_SUITE(TestMemCopy) {
}
}
- Y_UNIT_TEST(TestEmpty) {
+ Y_UNIT_TEST(TestEmpty) {
char* tmp = nullptr;
UNIT_ASSERT(MemCopy(tmp, tmp, 0) == nullptr);
diff --git a/util/generic/objects_counter_ut.cpp b/util/generic/objects_counter_ut.cpp
index cfa6ca6a3c..4d5da37a56 100644
--- a/util/generic/objects_counter_ut.cpp
+++ b/util/generic/objects_counter_ut.cpp
@@ -2,11 +2,11 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(ObjectsCounter) {
+Y_UNIT_TEST_SUITE(ObjectsCounter) {
struct TObject: public TObjectCounter<TObject> {
};
- Y_UNIT_TEST(Test1) {
+ Y_UNIT_TEST(Test1) {
TObject obj;
TVector<TObject> objects;
for (ui32 i = 0; i < 100; ++i) {
@@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(ObjectsCounter) {
UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 101);
}
- Y_UNIT_TEST(TestEq) {
+ Y_UNIT_TEST(TestEq) {
TObject obj;
{
TObject obj1 = obj;
@@ -24,7 +24,7 @@ Y_UNIT_TEST_SUITE(ObjectsCounter) {
UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 1);
}
- Y_UNIT_TEST(TestMove) {
+ Y_UNIT_TEST(TestMove) {
TObject obj;
UNIT_ASSERT_EQUAL(TObjectCounter<TObject>::ObjectCount(), 1);
{
diff --git a/util/generic/ptr.h b/util/generic/ptr.h
index 221519cb38..19db0e3ec5 100644
--- a/util/generic/ptr.h
+++ b/util/generic/ptr.h
@@ -122,7 +122,7 @@ public:
#endif
inline explicit operator bool() const noexcept {
- return nullptr != AsT();
+ return nullptr != AsT();
}
protected:
@@ -132,7 +132,7 @@ protected:
static inline T* DoRelease(T*& t) noexcept {
T* ret = t;
- t = nullptr;
+ t = nullptr;
return ret;
}
};
@@ -141,13 +141,13 @@ template <class Base, class T>
class TPointerBase: public TPointerCommon<Base, T> {
public:
inline T& operator*() const noexcept {
- Y_ASSERT(this->AsT());
+ Y_ASSERT(this->AsT());
return *(this->AsT());
}
inline T& operator[](size_t n) const noexcept {
- Y_ASSERT(this->AsT());
+ Y_ASSERT(this->AsT());
return (this->AsT())[n];
}
@@ -253,11 +253,11 @@ public:
}
template <class U, class = TGuardConversion<T, U>>
- inline THolder(TAutoPtr<U, D> t) noexcept
- : T_(t.Release())
- {
- }
-
+ inline THolder(TAutoPtr<U, D> t) noexcept
+ : T_(t.Release())
+ {
+ }
+
inline THolder(THolder&& that) noexcept
: T_(that.Release())
{
@@ -277,7 +277,7 @@ public:
}
inline void Destroy() noexcept {
- Reset(nullptr);
+ Reset(nullptr);
}
inline T* Release() noexcept Y_WARN_UNUSED_RESULT {
@@ -379,7 +379,7 @@ public:
inline void UnRef(TAtomicBase d) noexcept {
auto resultCount = Counter_.Sub(d);
- Y_ASSERT(resultCount >= 0);
+ Y_ASSERT(resultCount >= 0);
if (resultCount == 0) {
D::Destroy(static_cast<T*>(this));
}
@@ -427,7 +427,7 @@ struct TThrRefBase: public TRefCounted<TThrRefBase, TAtomicCounter> {
*
* @warning Additional care should be taken with regard to inheritance. If used
* as a base class, @p T should either declare a virtual destructor, or be
- * derived from @p TThrRefBase instead. Otherwise, only destructor of class @p T
+ * derived from @p TThrRefBase instead. Otherwise, only destructor of class @p T
* would be called, potentially slicing the object and creating memory leaks.
*
* @note To avoid accidental inheritance when it is not originally intended,
@@ -449,31 +449,31 @@ template <class T>
class TDefaultIntrusivePtrOps {
public:
static inline void Ref(T* t) noexcept {
- Y_ASSERT(t);
+ Y_ASSERT(t);
t->Ref();
}
static inline void UnRef(T* t) noexcept {
- Y_ASSERT(t);
+ Y_ASSERT(t);
t->UnRef();
}
static inline void DecRef(T* t) noexcept {
- Y_ASSERT(t);
+ Y_ASSERT(t);
t->DecRef();
}
static inline long RefCount(const T* t) noexcept {
- Y_ASSERT(t);
+ Y_ASSERT(t);
return t->RefCount();
}
};
-template <class T, class Ops>
+template <class T, class Ops>
class TIntrusivePtr: public TPointerBase<TIntrusivePtr<T, Ops>, T> {
template <class U, class O>
friend class TIntrusivePtr;
@@ -509,7 +509,7 @@ public:
}
// NOTE:
- // without std::enable_if_t compiler sometimes tries to use this constructor inappropriately
+ // without std::enable_if_t compiler sometimes tries to use this constructor inappropriately
// e.g.
// struct A {};
// struct B {};
@@ -611,7 +611,7 @@ struct THash<TIntrusivePtr<T, Ops>>: THash<const T*> {
};
// Behaves like TIntrusivePtr but returns const T* to prevent user from accidentally modifying the referenced object.
-template <class T, class Ops>
+template <class T, class Ops>
class TIntrusiveConstPtr: public TPointerBase<TIntrusiveConstPtr<T, Ops>, const T> {
public:
inline TIntrusiveConstPtr(T* t = nullptr) noexcept // we need a non-const pointer to Ref(), UnRef() and eventually delete it.
@@ -683,7 +683,7 @@ public:
}
inline void Drop() noexcept {
- TIntrusiveConstPtr(nullptr).Swap(*this);
+ TIntrusiveConstPtr(nullptr).Swap(*this);
}
inline long RefCount() const noexcept {
@@ -698,13 +698,13 @@ public:
#endif
private:
inline void Ref() noexcept {
- if (T_ != nullptr) {
+ if (T_ != nullptr) {
Ops::Ref(T_);
}
}
inline void UnRef() noexcept {
- if (T_ != nullptr) {
+ if (T_ != nullptr) {
Ops::UnRef(T_);
}
}
@@ -773,10 +773,10 @@ private:
};
template <class T, class Ops>
-typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::Ref_ = nullptr;
+typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::Ref_ = nullptr;
template <class T, class Ops>
-typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::UnRef_ = nullptr;
+typename TSimpleIntrusiveOps<T, Ops>::TFunc TSimpleIntrusiveOps<T, Ops>::UnRef_ = nullptr;
template <typename T, class Ops = TDefaultIntrusivePtrOps<T>, typename... Args>
[[nodiscard]] TIntrusivePtr<T, Ops> MakeIntrusive(Args&&... args) {
@@ -903,7 +903,7 @@ public:
private:
template <class X>
inline void Init(X& t) {
- C_ = !!t ? new C(1) : nullptr;
+ C_ = !!t ? new C(1) : nullptr;
T_ = t.Release();
}
@@ -968,7 +968,7 @@ public:
static inline T* Copy(T* t) {
if (t)
return t->Clone();
- return nullptr;
+ return nullptr;
}
};
@@ -978,7 +978,7 @@ public:
static inline T* Copy(T* t) {
if (t)
return new T(*t);
- return nullptr;
+ return nullptr;
}
};
@@ -1027,7 +1027,7 @@ public:
}
inline void Destroy() noexcept {
- Reset(nullptr);
+ Reset(nullptr);
}
inline void Swap(TCopyPtr& r) noexcept {
@@ -1055,7 +1055,7 @@ private:
};
// Copy-on-write pointer
-template <class TPtr, class TCopy>
+template <class TPtr, class TCopy>
class TCowPtr: public TPointerBase<TCowPtr<TPtr, TCopy>, const typename TPtr::TValueType> {
using T = typename TPtr::TValueType;
diff --git a/util/generic/ptr_ut.cpp b/util/generic/ptr_ut.cpp
index fa4d206128..c2dcff23f6 100644
--- a/util/generic/ptr_ut.cpp
+++ b/util/generic/ptr_ut.cpp
@@ -6,7 +6,7 @@
#include <util/generic/hash_set.h>
#include <util/generic/is_in.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/system/thread.h>
class TPointerTest: public TTestBase {
@@ -41,7 +41,7 @@ private:
struct S: public TAtomicRefCount<S> {
};
- struct TLocalThread: public ISimpleThread {
+ struct TLocalThread: public ISimpleThread {
void* ThreadProc() override {
TSimpleIntrusivePtr<S> ptr;
return nullptr;
@@ -259,23 +259,23 @@ void TPointerTest::TestAutoToHolder() {
}
UNIT_ASSERT_VALUES_EQUAL(cnt, 0);
-
- {
- TAutoPtr<A> x(new A());
- THolder<const A> y = x;
- }
-
- UNIT_ASSERT_VALUES_EQUAL(cnt, 0);
-
- {
+
+ {
+ TAutoPtr<A> x(new A());
+ THolder<const A> y = x;
+ }
+
+ UNIT_ASSERT_VALUES_EQUAL(cnt, 0);
+
+ {
class B1: public A {
- };
-
+ };
+
TAutoPtr<B1> x(new B1());
- THolder<A> y = x;
- }
-
- UNIT_ASSERT_VALUES_EQUAL(cnt, 0);
+ THolder<A> y = x;
+ }
+
+ UNIT_ASSERT_VALUES_EQUAL(cnt, 0);
}
void TPointerTest::TestCopyPtr() {
diff --git a/util/generic/queue_ut.cpp b/util/generic/queue_ut.cpp
index 3bccb506b9..a33399e104 100644
--- a/util/generic/queue_ut.cpp
+++ b/util/generic/queue_ut.cpp
@@ -6,8 +6,8 @@
#include <utility>
-Y_UNIT_TEST_SUITE(TYQueueTest) {
- Y_UNIT_TEST(ConstructorsAndAssignments) {
+Y_UNIT_TEST_SUITE(TYQueueTest) {
+ Y_UNIT_TEST(ConstructorsAndAssignments) {
{
using container = TQueue<int>;
@@ -73,7 +73,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
}
}
- Y_UNIT_TEST(pqueue1) {
+ Y_UNIT_TEST(pqueue1) {
TPriorityQueue<int, TDeque<int>, TLess<int>> q;
q.push(42);
@@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
UNIT_ASSERT(q.empty());
}
- Y_UNIT_TEST(pqueue2) {
+ Y_UNIT_TEST(pqueue2) {
using TPQueue = TPriorityQueue<int, TDeque<int>, TLess<int>>;
TPQueue q;
@@ -117,7 +117,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
UNIT_ASSERT(q.empty());
}
- Y_UNIT_TEST(pqueue3) {
+ Y_UNIT_TEST(pqueue3) {
TPriorityQueue<int, TDeque<int>, TLess<int>> q;
q.push(42);
@@ -128,7 +128,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
UNIT_ASSERT(q.empty());
}
- Y_UNIT_TEST(pqueue4) {
+ Y_UNIT_TEST(pqueue4) {
TDeque<int> c;
c.push_back(42);
c.push_back(101);
@@ -152,7 +152,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
UNIT_ASSERT(q.empty());
}
- Y_UNIT_TEST(queue1) {
+ Y_UNIT_TEST(queue1) {
TQueue<int, TList<int>> q;
q.push(42);
@@ -170,7 +170,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
UNIT_ASSERT(q.empty());
}
- Y_UNIT_TEST(queue2) {
+ Y_UNIT_TEST(queue2) {
using TQueueType = TQueue<int>;
TQueueType q;
@@ -196,7 +196,7 @@ Y_UNIT_TEST_SUITE(TYQueueTest) {
UNIT_ASSERT(q.empty());
}
- Y_UNIT_TEST(queue3) {
+ Y_UNIT_TEST(queue3) {
using TQueueType = TQueue<int>;
TQueueType q;
diff --git a/util/generic/refcount.h b/util/generic/refcount.h
index 9aee427990..966e853b77 100644
--- a/util/generic/refcount.h
+++ b/util/generic/refcount.h
@@ -74,7 +74,7 @@ public:
protected:
inline void Check() const {
- Y_VERIFY(ThreadId == SystemCurrentThreadId(), "incorrect usage of TSimpleCounter");
+ Y_VERIFY(ThreadId == SystemCurrentThreadId(), "incorrect usage of TSimpleCounter");
}
private:
diff --git a/util/generic/scope.h b/util/generic/scope.h
index a54ffc2644..b2c33af61e 100644
--- a/util/generic/scope.h
+++ b/util/generic/scope.h
@@ -38,28 +38,28 @@ namespace NPrivate {
};
}
-// \brief `Y_SCOPE_EXIT(captures) { body };`
-//
-// General implementaion of RAII idiom (resource acquisition is initialization). Executes
-// function upon return from the current scope.
-//
+// \brief `Y_SCOPE_EXIT(captures) { body };`
+//
+// General implementaion of RAII idiom (resource acquisition is initialization). Executes
+// function upon return from the current scope.
+//
// @note expects `body` to provide no-throw guarantee, otherwise whenever an exception
// is thrown and leaves the outermost block of `body`, the function `std::terminate` is called.
-// @see http://drdobbs.com/184403758 for detailed motivation.
+// @see http://drdobbs.com/184403758 for detailed motivation.
#define Y_SCOPE_EXIT(...) const auto Y_GENERATE_UNIQUE_ID(scopeGuard) Y_DECLARE_UNUSED = ::NPrivate::TMakeGuardHelper{} | [__VA_ARGS__]() mutable -> void
-
-// \brief `Y_DEFER { body };`
-//
-// Same as `Y_SCOPE_EXIT` but doesn't require user to provide capture-list explicitly (it
+
+// \brief `Y_DEFER { body };`
+//
+// Same as `Y_SCOPE_EXIT` but doesn't require user to provide capture-list explicitly (it
// implicitly uses `[&]` capture). Have same requirements for `body`.
-//
-// Inspired by `defer` statement in languages like Swift and Go.
-//
-// \code
-// auto item = s.pop();
-// bool ok = false;
-// Y_DEFER { if (!ok) { s.push(std::move(item)); } };
-// ... try handle `item` ...
-// ok = true;
-// \endcode
+//
+// Inspired by `defer` statement in languages like Swift and Go.
+//
+// \code
+// auto item = s.pop();
+// bool ok = false;
+// Y_DEFER { if (!ok) { s.push(std::move(item)); } };
+// ... try handle `item` ...
+// ok = true;
+// \endcode
#define Y_DEFER Y_SCOPE_EXIT(&)
diff --git a/util/generic/scope_ut.cpp b/util/generic/scope_ut.cpp
index d5aec0e8b6..bdb434d487 100644
--- a/util/generic/scope_ut.cpp
+++ b/util/generic/scope_ut.cpp
@@ -3,8 +3,8 @@
#include <util/generic/ptr.h>
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(ScopeToolsTest) {
- Y_UNIT_TEST(OnScopeExitTest) {
+Y_UNIT_TEST_SUITE(ScopeToolsTest) {
+ Y_UNIT_TEST(OnScopeExitTest) {
int i = 0;
{
@@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(ScopeToolsTest) {
UNIT_ASSERT_VALUES_EQUAL(2, i);
}
- Y_UNIT_TEST(OnScopeExitMoveTest) {
+ Y_UNIT_TEST(OnScopeExitMoveTest) {
THolder<int> i{new int{10}};
int p = 0;
diff --git a/util/generic/set_ut.cpp b/util/generic/set_ut.cpp
index 6c335080c0..d2769d327f 100644
--- a/util/generic/set_ut.cpp
+++ b/util/generic/set_ut.cpp
@@ -6,8 +6,8 @@
#include <algorithm>
-Y_UNIT_TEST_SUITE(YSetTest) {
- Y_UNIT_TEST(TestSet1) {
+Y_UNIT_TEST_SUITE(YSetTest) {
+ Y_UNIT_TEST(TestSet1) {
TSet<int, TLess<int>> s;
UNIT_ASSERT(!s);
UNIT_ASSERT(s.count(42) == 0);
@@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
UNIT_ASSERT(count == 1);
}
- Y_UNIT_TEST(TestSet2) {
+ Y_UNIT_TEST(TestSet2) {
using int_set = TSet<int, TLess<int>>;
int_set s;
std::pair<int_set::iterator, bool> p = s.insert(42);
@@ -45,7 +45,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
UNIT_ASSERT(distance(s3.begin(), s3.end()) == 5);
}
- Y_UNIT_TEST(TestErase) {
+ Y_UNIT_TEST(TestErase) {
TSet<int, TLess<int>> s;
s.insert(1);
s.erase(s.begin());
@@ -55,13 +55,13 @@ Y_UNIT_TEST_SUITE(YSetTest) {
UNIT_ASSERT(nb == 0);
}
- Y_UNIT_TEST(TestInsert) {
+ Y_UNIT_TEST(TestInsert) {
TSet<int> s;
TSet<int>::iterator i = s.insert(s.end(), 0);
UNIT_ASSERT(*i == 0);
}
- Y_UNIT_TEST(TestFind) {
+ Y_UNIT_TEST(TestFind) {
TSet<int> s;
UNIT_ASSERT(s.find(0) == s.end());
@@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
UNIT_ASSERT(crs.find(0) == crs.end());
}
- Y_UNIT_TEST(TestHas) {
+ Y_UNIT_TEST(TestHas) {
TSet<int> s;
UNIT_ASSERT(!s.contains(0));
@@ -89,7 +89,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
UNIT_ASSERT(s.contains(100));
}
- Y_UNIT_TEST(TestBounds) {
+ Y_UNIT_TEST(TestBounds) {
int array1[] = {1, 3, 6, 7};
TSet<int> s(array1, array1 + sizeof(array1) / sizeof(array1[0]));
TSet<int> const& crs = s;
@@ -155,7 +155,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
UNIT_ASSERT(*pcit.second == 7);
}
- Y_UNIT_TEST(TestImplementationCheck) {
+ Y_UNIT_TEST(TestImplementationCheck) {
TSet<int> tree;
tree.insert(1);
TSet<int>::iterator it = tree.begin();
@@ -170,7 +170,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
UNIT_ASSERT(int_cref == 1);
}
- Y_UNIT_TEST(TestReverseIteratorTest) {
+ Y_UNIT_TEST(TestReverseIteratorTest) {
TSet<int> tree;
tree.insert(1);
tree.insert(2);
@@ -191,7 +191,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
}
}
- Y_UNIT_TEST(TestConstructorsAndAssignments) {
+ Y_UNIT_TEST(TestConstructorsAndAssignments) {
{
using container = TSet<int>;
@@ -309,7 +309,7 @@ Y_UNIT_TEST_SUITE(YSetTest) {
using is_transparent = void;
};
- Y_UNIT_TEST(TestTemplateMethods) {
+ Y_UNIT_TEST(TestTemplateMethods) {
{
using KeySet = TSet<TKey, TKeyCmp>;
KeySet keySet;
diff --git a/util/generic/singleton.cpp b/util/generic/singleton.cpp
index cfe51e5e44..eb5a0662f8 100644
--- a/util/generic/singleton.cpp
+++ b/util/generic/singleton.cpp
@@ -29,8 +29,8 @@ namespace {
void NPrivate::FillWithTrash(void* ptr, size_t len) {
#if defined(NDEBUG)
- Y_UNUSED(ptr);
- Y_UNUSED(len);
+ Y_UNUSED(ptr);
+ Y_UNUSED(len);
#else
if constexpr (NSan::TSanIsOn()) {
Y_UNUSED(ptr);
@@ -44,7 +44,7 @@ void NPrivate::FillWithTrash(void* ptr, size_t len) {
void NPrivate::LockRecursive(TAtomic& lock) noexcept {
const TAtomicBase id = MyThreadId();
- Y_VERIFY(AtomicGet(lock) != id, "recursive singleton initialization");
+ Y_VERIFY(AtomicGet(lock) != id, "recursive singleton initialization");
if (!MyAtomicTryLock(lock, id)) {
TSpinWait sw;
@@ -56,6 +56,6 @@ void NPrivate::LockRecursive(TAtomic& lock) noexcept {
}
void NPrivate::UnlockRecursive(TAtomic& lock) noexcept {
- Y_VERIFY(AtomicGet(lock) == MyThreadId(), "unlock from another thread?!?!");
+ Y_VERIFY(AtomicGet(lock) == MyThreadId(), "unlock from another thread?!?!");
AtomicUnlock(&lock);
}
diff --git a/util/generic/singleton.h b/util/generic/singleton.h
index 38ee989c85..f5fa047f5c 100644
--- a/util/generic/singleton.h
+++ b/util/generic/singleton.h
@@ -8,7 +8,7 @@
template <class T>
struct TSingletonTraits {
- static constexpr size_t Priority = 65536;
+ static constexpr size_t Priority = 65536;
};
namespace NPrivate {
diff --git a/util/generic/singleton_ut.cpp b/util/generic/singleton_ut.cpp
index 45a9852da3..35ba90cd76 100644
--- a/util/generic/singleton_ut.cpp
+++ b/util/generic/singleton_ut.cpp
@@ -2,13 +2,13 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TestSingleton) {
+Y_UNIT_TEST_SUITE(TestSingleton) {
struct THuge {
char Buf[1000000];
int V = 1234;
};
- Y_UNIT_TEST(TestHuge) {
+ Y_UNIT_TEST(TestHuge) {
UNIT_ASSERT_VALUES_EQUAL(*HugeSingleton<int>(), 0);
UNIT_ASSERT_VALUES_EQUAL(HugeSingleton<THuge>()->V, 1234);
}
@@ -24,13 +24,13 @@ Y_UNIT_TEST_SUITE(TestSingleton) {
TString Data2;
};
- Y_UNIT_TEST(TestConstructorParamsOrder) {
+ Y_UNIT_TEST(TestConstructorParamsOrder) {
UNIT_ASSERT_VALUES_EQUAL(Singleton<TWithParams>(10, "123123")->Data1, 10);
UNIT_ASSERT_VALUES_EQUAL(Singleton<TWithParams>(20, "123123")->Data1, 10);
UNIT_ASSERT_VALUES_EQUAL(Singleton<TWithParams>(10, "456456")->Data2, "123123");
}
- Y_UNIT_TEST(TestInstantiationWithConstructorParams) {
+ Y_UNIT_TEST(TestInstantiationWithConstructorParams) {
UNIT_ASSERT_VALUES_EQUAL(Singleton<TWithParams>(10)->Data1, 10);
UNIT_ASSERT_VALUES_EQUAL(HugeSingleton<TWithParams>(20, "123123")->Data2, "123123");
{
diff --git a/util/generic/stack_ut.cpp b/util/generic/stack_ut.cpp
index b63e23711e..248127d326 100644
--- a/util/generic/stack_ut.cpp
+++ b/util/generic/stack_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TYStackTest) {
- Y_UNIT_TEST(ExplicitBool) {
+Y_UNIT_TEST_SUITE(TYStackTest) {
+ Y_UNIT_TEST(ExplicitBool) {
TStack<int> s;
UNIT_ASSERT(!s);
diff --git a/util/generic/strbase.h b/util/generic/strbase.h
index 862a427077..ab39fc7537 100644
--- a/util/generic/strbase.h
+++ b/util/generic/strbase.h
@@ -46,7 +46,7 @@ public:
using size_type = size_t;
using difference_type = ptrdiff_t;
- static constexpr size_t npos = size_t(-1);
+ static constexpr size_t npos = size_t(-1);
using const_iterator = const TCharType*;
using const_reference = const TCharType&;
@@ -144,13 +144,13 @@ public:
}
inline const_iterator cbegin() const noexcept {
- return begin();
- }
-
+ return begin();
+ }
+
inline const_iterator cend() const noexcept {
- return end();
- }
-
+ return end();
+ }
+
inline const_reverse_iterator rbegin() const noexcept {
return const_reverse_iterator(Ptr() + size());
}
@@ -294,35 +294,35 @@ public:
return equal(LegacySubString(*this, p, n), LegacySubString(t, 0, n1));
}
- static inline bool StartsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept {
+ static inline bool StartsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept {
return withLen <= whatLen && TStringViewWithTraits(what, withLen) == TStringViewWithTraits(with, withLen);
}
- static inline bool EndsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept {
+ static inline bool EndsWith(const TCharType* what, size_t whatLen, const TCharType* with, size_t withLen) noexcept {
return withLen <= whatLen && TStringViewWithTraits(what + whatLen - withLen, withLen) == TStringViewWithTraits(with, withLen);
}
- inline bool StartsWith(const TCharType* s, size_t n) const noexcept {
- return StartsWith(Ptr(), Len(), s, n);
+ inline bool StartsWith(const TCharType* s, size_t n) const noexcept {
+ return StartsWith(Ptr(), Len(), s, n);
}
inline bool StartsWith(const TStringView s) const noexcept {
return StartsWith(s.data(), s.length());
}
- inline bool StartsWith(TCharType ch) const noexcept {
+ inline bool StartsWith(TCharType ch) const noexcept {
return !empty() && TTraits::eq(*Ptr(), ch);
}
- inline bool EndsWith(const TCharType* s, size_t n) const noexcept {
- return EndsWith(Ptr(), Len(), s, n);
+ inline bool EndsWith(const TCharType* s, size_t n) const noexcept {
+ return EndsWith(Ptr(), Len(), s, n);
}
inline bool EndsWith(const TStringView s) const noexcept {
return EndsWith(s.data(), s.length());
}
- inline bool EndsWith(TCharType ch) const noexcept {
+ inline bool EndsWith(TCharType ch) const noexcept {
return !empty() && TTraits::eq(Ptr()[Len() - 1], ch);
}
@@ -432,7 +432,7 @@ public:
// ~~ Read access ~~
inline TCharType at(size_t pos) const noexcept {
- if (Y_LIKELY(pos < Len())) {
+ if (Y_LIKELY(pos < Len())) {
return (Ptr())[pos];
}
return 0;
diff --git a/util/generic/strbuf.h b/util/generic/strbuf.h
index 3c046ea8a3..70b9360d58 100644
--- a/util/generic/strbuf.h
+++ b/util/generic/strbuf.h
@@ -153,9 +153,9 @@ public:
inline TBasicStringBuf(const TBasicStringBuf& src, size_t pos) noexcept
: TBasicStringBuf(src, pos, TBase::npos)
- {
- }
-
+ {
+ }
+
Y_PURE_FUNCTION inline TBasicStringBuf SubString(size_t pos, size_t n) const noexcept {
pos = Min(pos, size());
n = Min(n, size() - pos);
@@ -290,7 +290,7 @@ public:
SplitOn(pos, l, r, 0);
}
- /*
+ /*
// Not implemented intentionally, use TrySplitOn() instead
void RSplitOn(size_t pos, TdSelf& l, TdSelf& r) const noexcept;
void RSplitAt(size_t pos, TdSelf& l, TdSelf& r) const noexcept;
@@ -319,7 +319,7 @@ public:
public:
inline bool AfterPrefix(const TdSelf& prefix, TdSelf& result) const noexcept {
- if (this->StartsWith(prefix)) {
+ if (this->StartsWith(prefix)) {
result = Tail(prefix.size());
return true;
}
@@ -327,7 +327,7 @@ public:
}
inline bool BeforeSuffix(const TdSelf& suffix, TdSelf& result) const noexcept {
- if (this->EndsWith(suffix)) {
+ if (this->EndsWith(suffix)) {
result = Head(size() - suffix.size());
return true;
}
@@ -370,7 +370,7 @@ public:
SplitOn(pos, tok, *this);
return tok;
}
- /*
+ /*
// See comment on RSplitOn() above
TdSelf RSplitOffOn(size_t pos);
TdSelf RNextTokOn(size_t pos);
diff --git a/util/generic/strbuf_ut.cpp b/util/generic/strbuf_ut.cpp
index 106bb097d5..69cde785af 100644
--- a/util/generic/strbuf_ut.cpp
+++ b/util/generic/strbuf_ut.cpp
@@ -4,7 +4,7 @@
#include <string_view>
-Y_UNIT_TEST_SUITE(TStrBufTest) {
+Y_UNIT_TEST_SUITE(TStrBufTest) {
Y_UNIT_TEST(TestConstructorsAndOperators) {
TStringBuf str("qwerty");
@@ -27,7 +27,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_EQUAL(helloWorld.size(), fromStringBuf.size());
}
- Y_UNIT_TEST(TestConstExpr) {
+ Y_UNIT_TEST(TestConstExpr) {
static constexpr TStringBuf str1("qwe\0rty", 7);
static constexpr TStringBuf str2(str1.data(), str1.size());
static constexpr TStringBuf str3 = "qwe\0rty"sv;
@@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
static_assert(str1.size() == str4.size());
}
- Y_UNIT_TEST(TestAfter) {
+ Y_UNIT_TEST(TestAfter) {
TStringBuf str("qwerty");
UNIT_ASSERT_VALUES_EQUAL(str.After('w'), TStringBuf("erty"));
@@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_STRINGS_EQUAL(empty.After('x'), empty);
}
- Y_UNIT_TEST(TestBefore) {
+ Y_UNIT_TEST(TestBefore) {
TStringBuf str("qwerty");
UNIT_ASSERT_VALUES_EQUAL(str.Before('w'), TStringBuf("q"));
@@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_VALUES_EQUAL(str.Before('q'), TStringBuf());
}
- Y_UNIT_TEST(TestRAfterBefore) {
+ Y_UNIT_TEST(TestRAfterBefore) {
TStringBuf str("a/b/c");
UNIT_ASSERT_STRINGS_EQUAL(str.RAfter('/'), "c");
UNIT_ASSERT_STRINGS_EQUAL(str.RAfter('_'), str);
@@ -81,7 +81,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_STRINGS_EQUAL(str.RBefore('a'), "");
}
- Y_UNIT_TEST(TestAfterPrefix) {
+ Y_UNIT_TEST(TestAfterPrefix) {
TStringBuf str("cat_dog");
TStringBuf r = "the_same";
@@ -108,7 +108,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT(!a.SkipPrefix("def") && a == "");
}
- Y_UNIT_TEST(TestBeforeSuffix) {
+ Y_UNIT_TEST(TestBeforeSuffix) {
TStringBuf str("cat_dog");
TStringBuf r = "the_same";
@@ -135,12 +135,12 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT(!a.ChopSuffix("abc") && a == "");
}
- Y_UNIT_TEST(TestEmpty) {
+ Y_UNIT_TEST(TestEmpty) {
UNIT_ASSERT(TStringBuf().empty());
UNIT_ASSERT(!TStringBuf("q").empty());
}
- Y_UNIT_TEST(TestShift) {
+ Y_UNIT_TEST(TestShift) {
TStringBuf qw("qwerty");
TStringBuf str;
@@ -155,7 +155,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_EQUAL(str, TStringBuf("rt"));
}
- Y_UNIT_TEST(TestSplit) {
+ Y_UNIT_TEST(TestSplit) {
TStringBuf qw("qwerty");
TStringBuf lt, rt;
@@ -176,7 +176,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_EQUAL(ty, TStringBuf("ty"));
}
- Y_UNIT_TEST(TestNextTok) {
+ Y_UNIT_TEST(TestNextTok) {
TStringBuf buf("12q45q");
TStringBuf tok;
@@ -185,7 +185,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT(!buf.NextTok('q', tok));
}
- Y_UNIT_TEST(TestNextStringTok) {
+ Y_UNIT_TEST(TestNextStringTok) {
TStringBuf buf1("a@@b@@c");
UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("a"));
UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("b"));
@@ -203,7 +203,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_EQUAL(buf3, TStringBuf());
}
- Y_UNIT_TEST(TestReadLine) {
+ Y_UNIT_TEST(TestReadLine) {
TStringBuf buf("12\n45\r\n\r\n23");
TStringBuf tok;
@@ -222,7 +222,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT(!buf.ReadLine(tok));
}
- Y_UNIT_TEST(TestRFind) {
+ Y_UNIT_TEST(TestRFind) {
TStringBuf buf1 = "123123456";
UNIT_ASSERT_EQUAL(buf1.rfind('3'), 5);
UNIT_ASSERT_EQUAL(buf1.rfind('4'), 6);
@@ -240,7 +240,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_EQUAL(buf4.rfind('3'), 2);
}
- Y_UNIT_TEST(TestRNextTok) {
+ Y_UNIT_TEST(TestRNextTok) {
TStringBuf buf1("a.b.c");
UNIT_ASSERT_EQUAL(buf1.RNextTok('.'), TStringBuf("c"));
UNIT_ASSERT_EQUAL(buf1, TStringBuf("a.b"));
@@ -256,7 +256,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT(!buf3.RNextTok(' ', tok) && tok == "ab" && buf3 == ""); // not modified
}
- Y_UNIT_TEST(TestRSplitOff) {
+ Y_UNIT_TEST(TestRSplitOff) {
TStringBuf buf1("a.b.c");
UNIT_ASSERT_EQUAL(buf1.RSplitOff('.'), TStringBuf("a.b"));
UNIT_ASSERT_EQUAL(buf1, TStringBuf("c"));
@@ -265,18 +265,18 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_EQUAL(buf2.RSplitOff('.'), TStringBuf());
UNIT_ASSERT_EQUAL(buf2, TStringBuf("a"));
}
-
- Y_UNIT_TEST(TestCBeginCEnd) {
- const char helloThere[] = "Hello there";
- TStringBuf s{helloThere};
-
- size_t index = 0;
- for (auto it = s.cbegin(); s.cend() != it; ++it, ++index) {
- UNIT_ASSERT_VALUES_EQUAL(helloThere[index], *it);
- }
- }
-
- Y_UNIT_TEST(TestSplitOnAt) {
+
+ Y_UNIT_TEST(TestCBeginCEnd) {
+ const char helloThere[] = "Hello there";
+ TStringBuf s{helloThere};
+
+ size_t index = 0;
+ for (auto it = s.cbegin(); s.cend() != it; ++it, ++index) {
+ UNIT_ASSERT_VALUES_EQUAL(helloThere[index], *it);
+ }
+ }
+
+ Y_UNIT_TEST(TestSplitOnAt) {
TStringBuf s = "abcabc";
TStringBuf l, r;
@@ -296,28 +296,28 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
// out of range
pos = 100500;
- UNIT_ASSERT(s.TrySplitOn(pos, l, r)); // still true
+ UNIT_ASSERT(s.TrySplitOn(pos, l, r)); // still true
UNIT_ASSERT(l == "abcabc" && r == "");
- l = "111";
- r = "222";
- UNIT_ASSERT(s.TrySplitAt(pos, l, r)); // still true
+ l = "111";
+ r = "222";
+ UNIT_ASSERT(s.TrySplitAt(pos, l, r)); // still true
UNIT_ASSERT(l == "abcabc" && r == "");
// npos
pos = s.find("missing");
- l = "111";
- r = "222";
+ l = "111";
+ r = "222";
UNIT_ASSERT(!s.TrySplitOn(pos, l, r));
- UNIT_ASSERT(l == "111" && r == "222"); // not modified
+ UNIT_ASSERT(l == "111" && r == "222"); // not modified
s.SplitOn(pos, l, r);
- UNIT_ASSERT(l == "abcabc" && r == ""); // modified
+ UNIT_ASSERT(l == "abcabc" && r == ""); // modified
- l = "111";
- r = "222";
+ l = "111";
+ r = "222";
UNIT_ASSERT(!s.TrySplitAt(pos, l, r));
- UNIT_ASSERT(l == "111" && r == "222"); // not modified
+ UNIT_ASSERT(l == "111" && r == "222"); // not modified
s.SplitAt(pos, l, r);
- UNIT_ASSERT(l == "abcabc" && r == ""); // modified
+ UNIT_ASSERT(l == "abcabc" && r == ""); // modified
}
template <class T>
@@ -328,7 +328,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT(TStringBuf(val).size() == 5);
}
- Y_UNIT_TEST(TestPassingArraysByConstReference) {
+ Y_UNIT_TEST(TestPassingArraysByConstReference) {
char data[] = "Hello\0word";
PassByConstReference(data);
}
diff --git a/util/generic/string.h b/util/generic/string.h
index fc2109198a..8cd8aa6917 100644
--- a/util/generic/string.h
+++ b/util/generic/string.h
@@ -1067,7 +1067,7 @@ public:
}
TBasicString& pop_back() Y_NOEXCEPT {
- Y_ASSERT(!this->empty());
+ Y_ASSERT(!this->empty());
MutRef().pop_back();
diff --git a/util/generic/string_transparent_hash_ut.cpp b/util/generic/string_transparent_hash_ut.cpp
index 00c9f3bafa..b87fa2843e 100644
--- a/util/generic/string_transparent_hash_ut.cpp
+++ b/util/generic/string_transparent_hash_ut.cpp
@@ -1,19 +1,19 @@
#include "string.h"
#include "vector.h"
-#include "strbuf.h"
+#include "strbuf.h"
#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/containers/absl_flat_hash/flat_hash_set.h>
-#include <util/str_stl.h>
+#include <util/str_stl.h>
-Y_UNIT_TEST_SUITE(StringHashFunctorTests) {
- Y_UNIT_TEST(TestTransparencyWithUnorderedSet) {
- // Using Abseil hash set because `std::unordered_set` is transparent only from C++20 (while
- // we stuck with C++17 right now).
- absl::flat_hash_set<TString, THash<TString>, TEqualTo<TString>> s = {"foo"};
- // If either `THash` or `TEqualTo` is not transparent compilation will fail.
- UNIT_ASSERT_UNEQUAL(s.find(TStringBuf("foo")), s.end());
- UNIT_ASSERT_EQUAL(s.find(TStringBuf("bar")), s.end());
+Y_UNIT_TEST_SUITE(StringHashFunctorTests) {
+ Y_UNIT_TEST(TestTransparencyWithUnorderedSet) {
+ // Using Abseil hash set because `std::unordered_set` is transparent only from C++20 (while
+ // we stuck with C++17 right now).
+ absl::flat_hash_set<TString, THash<TString>, TEqualTo<TString>> s = {"foo"};
+ // If either `THash` or `TEqualTo` is not transparent compilation will fail.
+ UNIT_ASSERT_UNEQUAL(s.find(TStringBuf("foo")), s.end());
+ UNIT_ASSERT_EQUAL(s.find(TStringBuf("bar")), s.end());
}
}
diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp
index f96bec6480..ac82e9091d 100644
--- a/util/generic/string_ut.cpp
+++ b/util/generic/string_ut.cpp
@@ -5,7 +5,7 @@
#include "yexception.h"
#include <util/charset/wide.h>
-#include <util/str_stl.h>
+#include <util/str_stl.h>
#include <util/stream/output.h>
#include <util/string/subst.h>
@@ -30,8 +30,8 @@ public:
const char data[] = "abc\0def\0";
TString s(data, sizeof(data));
UNIT_ASSERT(s.size() == sizeof(data));
- UNIT_ASSERT(s.StartsWith(s));
- UNIT_ASSERT(s.EndsWith(s));
+ UNIT_ASSERT(s.StartsWith(s));
+ UNIT_ASSERT(s.EndsWith(s));
UNIT_ASSERT(s.Contains('\0'));
const char raw_def[] = "def";
@@ -54,7 +54,7 @@ public:
UNIT_ASSERT(s == copy);
TString prefix(data, 5);
- UNIT_ASSERT(s.StartsWith(prefix));
+ UNIT_ASSERT(s.StartsWith(prefix));
UNIT_ASSERT(s != prefix);
UNIT_ASSERT(s > prefix);
UNIT_ASSERT(s > s.data());
@@ -269,7 +269,7 @@ protected:
TStringType xx;
// ISO-IEC-14882:1998(E), 21.3.6, paragraph 3
- UNIT_ASSERT(xx.data() != nullptr);
+ UNIT_ASSERT(xx.data() != nullptr);
}
void c_str() {
@@ -537,15 +537,15 @@ protected:
}
}
- void cbegin_cend() {
- const char helloThere[] = "Hello there";
+ void cbegin_cend() {
+ const char helloThere[] = "Hello there";
TString s = helloThere;
- size_t index = 0;
- for (auto it = s.cbegin(); s.cend() != it; ++it, ++index) {
- UNIT_ASSERT_VALUES_EQUAL(helloThere[index], *it);
- }
- }
-
+ size_t index = 0;
+ for (auto it = s.cbegin(); s.cend() != it; ++it, ++index) {
+ UNIT_ASSERT_VALUES_EQUAL(helloThere[index], *it);
+ }
+ }
+
void compare() {
TStringType str1(Data_.abcdef());
TStringType str2;
@@ -1128,7 +1128,7 @@ public:
UNIT_TEST(capacity);
UNIT_TEST(assign);
UNIT_TEST(copy);
- UNIT_TEST(cbegin_cend);
+ UNIT_TEST(cbegin_cend);
UNIT_TEST(compare);
UNIT_TEST(find_last_of);
#if 0
@@ -1164,7 +1164,7 @@ public:
UNIT_TEST(capacity);
UNIT_TEST(assign);
UNIT_TEST(copy);
- UNIT_TEST(cbegin_cend);
+ UNIT_TEST(cbegin_cend);
UNIT_TEST(compare);
UNIT_TEST(find_last_of);
#if 0
@@ -1190,19 +1190,19 @@ Y_UNIT_TEST_SUITE(TStringConversionTest) {
UNIT_ASSERT_VALUES_EQUAL(stdAbra, "cadabra");
}
}
-
-Y_UNIT_TEST_SUITE(HashFunctorTests) {
- Y_UNIT_TEST(TestTransparency) {
- THash<TString> h;
- const char* ptr = "a";
- const TStringBuf strbuf = ptr;
- const TString str = ptr;
- const std::string stdStr = ptr;
- UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(strbuf));
- UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(str));
- UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(stdStr));
- }
-}
+
+Y_UNIT_TEST_SUITE(HashFunctorTests) {
+ Y_UNIT_TEST(TestTransparency) {
+ THash<TString> h;
+ const char* ptr = "a";
+ const TStringBuf strbuf = ptr;
+ const TString str = ptr;
+ const std::string stdStr = ptr;
+ UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(strbuf));
+ UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(str));
+ UNIT_ASSERT_VALUES_EQUAL(h(ptr), h(stdStr));
+ }
+}
#if !defined(TSTRING_IS_STD_STRING)
Y_UNIT_TEST_SUITE(StdNonConformant) {
diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h
index cd9db7876b..44bb10bdeb 100644
--- a/util/generic/string_ut.h
+++ b/util/generic/string_ut.h
@@ -981,21 +981,21 @@ public:
void TestPrefixSuffix() {
const TStringType emptyStr;
- UNIT_ASSERT_EQUAL(emptyStr.StartsWith('x'), false);
- UNIT_ASSERT_EQUAL(emptyStr.EndsWith('x'), false);
- UNIT_ASSERT_EQUAL(emptyStr.StartsWith(0), false);
- UNIT_ASSERT_EQUAL(emptyStr.EndsWith(0), false);
- UNIT_ASSERT_EQUAL(emptyStr.StartsWith(emptyStr), true);
- UNIT_ASSERT_EQUAL(emptyStr.EndsWith(emptyStr), true);
+ UNIT_ASSERT_EQUAL(emptyStr.StartsWith('x'), false);
+ UNIT_ASSERT_EQUAL(emptyStr.EndsWith('x'), false);
+ UNIT_ASSERT_EQUAL(emptyStr.StartsWith(0), false);
+ UNIT_ASSERT_EQUAL(emptyStr.EndsWith(0), false);
+ UNIT_ASSERT_EQUAL(emptyStr.StartsWith(emptyStr), true);
+ UNIT_ASSERT_EQUAL(emptyStr.EndsWith(emptyStr), true);
const char_type chars[] = {'h', 'e', 'l', 'l', 'o', 0};
const TStringType str(chars);
- UNIT_ASSERT_EQUAL(str.StartsWith('h'), true);
- UNIT_ASSERT_EQUAL(str.StartsWith('o'), false);
- UNIT_ASSERT_EQUAL(str.EndsWith('o'), true);
- UNIT_ASSERT_EQUAL(str.EndsWith('h'), false);
- UNIT_ASSERT_EQUAL(str.StartsWith(emptyStr), true);
- UNIT_ASSERT_EQUAL(str.EndsWith(emptyStr), true);
+ UNIT_ASSERT_EQUAL(str.StartsWith('h'), true);
+ UNIT_ASSERT_EQUAL(str.StartsWith('o'), false);
+ UNIT_ASSERT_EQUAL(str.EndsWith('o'), true);
+ UNIT_ASSERT_EQUAL(str.EndsWith('h'), false);
+ UNIT_ASSERT_EQUAL(str.StartsWith(emptyStr), true);
+ UNIT_ASSERT_EQUAL(str.EndsWith(emptyStr), true);
}
#ifndef TSTRING_IS_STD_STRING
diff --git a/util/generic/typelist.h b/util/generic/typelist.h
index 90d7e4239e..5ce26ab97c 100644
--- a/util/generic/typelist.h
+++ b/util/generic/typelist.h
@@ -1,7 +1,7 @@
#pragma once
-#include <util/system/types.h>
-
+#include <util/system/types.h>
+
#include <util/generic/typetraits.h>
#include <type_traits>
@@ -109,6 +109,6 @@ using TFixedWidthSignedInt = typename TFixedWidthSignedInts::template TSelectBy<
template <typename T>
using TFixedWidthUnsignedInt = typename TFixedWidthUnsignedInts::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
-
-template <typename T>
-using TFixedWidthFloat = typename TFloats::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
+
+template <typename T>
+using TFixedWidthFloat = typename TFloats::template TSelectBy<TSizeOfPredicate<sizeof(T)>::template TResult>::type;
diff --git a/util/generic/typelist_ut.cpp b/util/generic/typelist_ut.cpp
index e2872feab7..eeabfa97b1 100644
--- a/util/generic/typelist_ut.cpp
+++ b/util/generic/typelist_ut.cpp
@@ -10,7 +10,7 @@ class TTypeListTest: public TTestBase {
UNIT_TEST(TestSimple);
UNIT_TEST(TestHave);
UNIT_TEST(TestGet);
- UNIT_TEST(TestFloatList);
+ UNIT_TEST(TestFloatList);
UNIT_TEST(TestSelectBy);
UNIT_TEST_SUITE_END();
@@ -73,13 +73,13 @@ public:
using TMyMapPTATB = TMyMap<TA*, TB>;
UNIT_ASSERT_TYPES_EQUAL(TListType::TSelectBy<TIsNArgTemplate>::type, TMyMapPTATB);
}
-
- void TestFloatList() {
- UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<ui32>, float);
- UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<i32>, float);
- UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<ui64>, double);
- UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<i64>, double);
- }
+
+ void TestFloatList() {
+ UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<ui32>, float);
+ UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<i32>, float);
+ UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<ui64>, double);
+ UNIT_ASSERT_TYPES_EQUAL(TFixedWidthFloat<i64>, double);
+ }
};
UNIT_TEST_SUITE_REGISTRATION(TTypeListTest);
diff --git a/util/generic/typetraits.h b/util/generic/typetraits.h
index 57d07c62ff..d165bd1a06 100644
--- a/util/generic/typetraits.h
+++ b/util/generic/typetraits.h
@@ -1,6 +1,6 @@
#pragma once
-#include "va_args.h"
+#include "va_args.h"
#include <util/system/defaults.h>
@@ -115,7 +115,7 @@ public:
/*
* can be used in function templates for effective parameters passing
*/
- using TFuncParam = std::conditional_t<IsValueType, T, const std::remove_reference_t<T>&>;
+ using TFuncParam = std::conditional_t<IsValueType, T, const std::remove_reference_t<T>&>;
};
template <>
@@ -162,79 +162,79 @@ class TTypeTraits<void>: public TTypeTraitsBase<void> {};
struct THas##name \
: TBaseHas##name<T, std::is_class<T>::value || std::is_union<T>::value> {}
-#define Y_HAS_MEMBER_IMPL_1(name) Y_HAS_MEMBER_IMPL_2(name, name)
+#define Y_HAS_MEMBER_IMPL_1(name) Y_HAS_MEMBER_IMPL_2(name, name)
-/* @def Y_HAS_MEMBER
- *
- * This macro should be used to define compile-time introspection helper classes for template
- * metaprogramming.
- *
- * Macro accept one or two parameters, when used with two parameters e.g. `Y_HAS_MEMBER(xyz, ABC)`
+/* @def Y_HAS_MEMBER
+ *
+ * This macro should be used to define compile-time introspection helper classes for template
+ * metaprogramming.
+ *
+ * Macro accept one or two parameters, when used with two parameters e.g. `Y_HAS_MEMBER(xyz, ABC)`
* will define class `THasABC` with static member `value` of type bool. Usage with one parameter
- * e.g. `Y_HAS_MEMBER(xyz)` will produce the same result as `Y_HAS_MEMBER(xyz, xyz)`.
- *
- * @code
- * #include <type_traits>
- *
- * Y_HAS_MEMBER(push_front, PushFront);
- *
- * template <typename T, typename U>
+ * e.g. `Y_HAS_MEMBER(xyz)` will produce the same result as `Y_HAS_MEMBER(xyz, xyz)`.
+ *
+ * @code
+ * #include <type_traits>
+ *
+ * Y_HAS_MEMBER(push_front, PushFront);
+ *
+ * template <typename T, typename U>
* std::enable_if_t<THasPushFront<T>::value, void>
- * PushFront(T& container, const U value) {
- * container.push_front(x);
- * }
- *
- * template <typename T, typename U>
+ * PushFront(T& container, const U value) {
+ * container.push_front(x);
+ * }
+ *
+ * template <typename T, typename U>
* std::enable_if_t<!THasPushFront<T>::value, void>
- * PushFront(T& container, const U value) {
- * container.insert(container.begin(), x);
- * }
- * @endcode
- */
-#define Y_HAS_MEMBER(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_HAS_MEMBER_IMPL_2, Y_HAS_MEMBER_IMPL_1)(__VA_ARGS__))
-
+ * PushFront(T& container, const U value) {
+ * container.insert(container.begin(), x);
+ * }
+ * @endcode
+ */
+#define Y_HAS_MEMBER(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_HAS_MEMBER_IMPL_2, Y_HAS_MEMBER_IMPL_1)(__VA_ARGS__))
+
#define Y_HAS_SUBTYPE_IMPL_2(subtype, name) \
template <class T, class = void> \
struct THas##name: std::false_type {}; \
template <class T> \
struct THas##name<T, ::TVoidT<typename T::subtype>>: std::true_type {};
-#define Y_HAS_SUBTYPE_IMPL_1(name) Y_HAS_SUBTYPE_IMPL_2(name, name)
+#define Y_HAS_SUBTYPE_IMPL_1(name) Y_HAS_SUBTYPE_IMPL_2(name, name)
-/* @def Y_HAS_SUBTYPE
- *
- * This macro should be used to define compile-time introspection helper classes for template
- * metaprogramming.
- *
- * Macro accept one or two parameters, when used with two parameters e.g. `Y_HAS_SUBTYPE(xyz, ABC)`
+/* @def Y_HAS_SUBTYPE
+ *
+ * This macro should be used to define compile-time introspection helper classes for template
+ * metaprogramming.
+ *
+ * Macro accept one or two parameters, when used with two parameters e.g. `Y_HAS_SUBTYPE(xyz, ABC)`
* will define class `THasABC` with static member `value` of type bool. Usage with one parameter
- * e.g. `Y_HAS_SUBTYPE(xyz)` will produce the same result as `Y_HAS_SUBTYPE(xyz, xyz)`.
- *
- * @code
- * Y_HAS_MEMBER(find, FindMethod);
- * Y_HAS_SUBTYPE(const_iterator, ConstIterator);
- * Y_HAS_SUBTYPE(key_type, KeyType);
- *
- * template <typename T>
- * using TIsAssocCont = std::conditional_t<
+ * e.g. `Y_HAS_SUBTYPE(xyz)` will produce the same result as `Y_HAS_SUBTYPE(xyz, xyz)`.
+ *
+ * @code
+ * Y_HAS_MEMBER(find, FindMethod);
+ * Y_HAS_SUBTYPE(const_iterator, ConstIterator);
+ * Y_HAS_SUBTYPE(key_type, KeyType);
+ *
+ * template <typename T>
+ * using TIsAssocCont = std::conditional_t<
* THasFindMethod<T>::value && THasConstIterator<T>::value && THasKeyType<T>::value,
- * std::true_type,
- * std::false_type,
- * >;
- *
+ * std::true_type,
+ * std::false_type,
+ * >;
+ *
* static_assert(TIsAssocCont<TVector<int>>::value == false, "");
* static_assert(TIsAssocCont<THashMap<int>>::value == true, "");
- * @endcode
- */
-#define Y_HAS_SUBTYPE(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_HAS_SUBTYPE_IMPL_2, Y_HAS_SUBTYPE_IMPL_1)(__VA_ARGS__))
-
+ * @endcode
+ */
+#define Y_HAS_SUBTYPE(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_HAS_SUBTYPE_IMPL_2, Y_HAS_SUBTYPE_IMPL_1)(__VA_ARGS__))
+
template <class T1, class T2>
struct TPodTraits<std::pair<T1, T2>> {
enum {
IsPod = TTypeTraits<T1>::IsPod && TTypeTraits<T2>::IsPod
};
};
-
+
template <class T>
struct TIsPointerToConstMemberFunction: std::false_type {
};
diff --git a/util/generic/typetraits_ut.cpp b/util/generic/typetraits_ut.cpp
index 496e357dd7..e7571c75ec 100644
--- a/util/generic/typetraits_ut.cpp
+++ b/util/generic/typetraits_ut.cpp
@@ -78,13 +78,13 @@ namespace {
UNIT_ASSERT_C(x_, #x " != " #y); \
}
-Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
- Y_UNIT_TEST(TestIsSame) {
+Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
+ Y_UNIT_TEST(TestIsSame) {
UNIT_ASSERT((std::is_same<int, int>::value));
UNIT_ASSERT(!(std::is_same<signed int, unsigned int>::value));
}
- Y_UNIT_TEST(TestRemoveReference) {
+ Y_UNIT_TEST(TestRemoveReference) {
ASSERT_SAME_TYPE(std::remove_reference_t<int>, int);
ASSERT_SAME_TYPE(std::remove_reference_t<const int>, const int);
ASSERT_SAME_TYPE(std::remove_reference_t<int&>, int);
@@ -96,23 +96,23 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
ASSERT_SAME_TYPE(std::remove_reference_t<TIncompleteType&>, TIncompleteType);
}
- Y_UNIT_TEST(TestRemoveConst) {
+ Y_UNIT_TEST(TestRemoveConst) {
ASSERT_SAME_TYPE(std::remove_const_t<const int>, int);
}
- Y_UNIT_TEST(TestRemoveVolatile) {
+ Y_UNIT_TEST(TestRemoveVolatile) {
ASSERT_SAME_TYPE(std::remove_volatile_t<volatile int>, int);
}
- Y_UNIT_TEST(TestRemoveCV) {
+ Y_UNIT_TEST(TestRemoveCV) {
ASSERT_SAME_TYPE(std::remove_cv_t<const volatile int>, int);
}
- Y_UNIT_TEST(TestAddCV) {
+ Y_UNIT_TEST(TestAddCV) {
ASSERT_SAME_TYPE(std::add_cv_t<int>, const volatile int);
}
- Y_UNIT_TEST(TestClass) {
+ Y_UNIT_TEST(TestClass) {
UNIT_ASSERT(std::is_class<TString>::value);
UNIT_ASSERT(!std::is_class<ETestEnum>::value);
UNIT_ASSERT(!std::is_class<int>::value);
@@ -168,35 +168,35 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
UNIT_ASSERT(!std::is_signed<ETypedEnum>::value);
}
- Y_UNIT_TEST(TestBool) {
+ Y_UNIT_TEST(TestBool) {
TestArithmeticType<bool>();
TestUnsignedIntType<bool>();
}
- Y_UNIT_TEST(TestUnsignedChar) {
+ Y_UNIT_TEST(TestUnsignedChar) {
TestArithmeticType<unsigned char>();
TestUnsignedIntType<unsigned char>();
}
- Y_UNIT_TEST(TestSizeT) {
+ Y_UNIT_TEST(TestSizeT) {
TestArithmeticType<size_t>();
TestUnsignedIntType<size_t>();
}
- Y_UNIT_TEST(TestInt) {
+ Y_UNIT_TEST(TestInt) {
TestArithmeticType<int>();
TestSignedIntType<int>();
}
- Y_UNIT_TEST(TestDouble) {
+ Y_UNIT_TEST(TestDouble) {
TestArithmeticType<double>();
}
- Y_UNIT_TEST(TestLongDouble) {
+ Y_UNIT_TEST(TestLongDouble) {
TestArithmeticType<long double>();
}
- Y_UNIT_TEST(TestAddRValueReference) {
+ Y_UNIT_TEST(TestAddRValueReference) {
ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int>, int&&);
ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int const&>, int const&);
ASSERT_SAME_TYPE(std::add_rvalue_reference_t<int*>, int*&&);
@@ -205,7 +205,7 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
ASSERT_SAME_TYPE(std::add_rvalue_reference_t<void>, void);
}
- Y_UNIT_TEST(TestIsEmpty) {
+ Y_UNIT_TEST(TestIsEmpty) {
UNIT_ASSERT(std::is_empty<TEmptyClass>::value);
UNIT_ASSERT(std::is_empty<TEmptyDerivedClass>::value);
UNIT_ASSERT(std::is_empty<TAnotherEmptyClass>::value);
@@ -218,7 +218,7 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
UNIT_ASSERT(!std::is_empty<TNonEmptyDerivedClass>::value);
}
- Y_UNIT_TEST(TestIsStandardLayout) {
+ Y_UNIT_TEST(TestIsStandardLayout) {
UNIT_ASSERT(std::is_standard_layout<TStdLayoutClass1>::value);
UNIT_ASSERT(std::is_standard_layout<TStdLayoutClass2>::value);
UNIT_ASSERT(!std::is_standard_layout<TNonStdLayoutClass1>::value);
@@ -230,10 +230,10 @@ Y_UNIT_TEST_SUITE(TTypeTraitsTest) {
template <class T>
using TTrySum = decltype(std::declval<T>() + std::declval<T>());
- Y_UNIT_TEST(TestIsTriviallyCopyable) {
- struct TPod {
- int value;
- };
+ Y_UNIT_TEST(TestIsTriviallyCopyable) {
+ struct TPod {
+ int value;
+ };
struct TNontriviallyCopyAssignable {
TNontriviallyCopyAssignable(const TNontriviallyCopyAssignable&) = default;
@@ -381,7 +381,7 @@ namespace {
#define UNIT_ASSERT_EQUAL_ENUM(expected, actual) UNIT_ASSERT_VALUES_EQUAL((bool)(expected), (bool)(actual))
-Y_UNIT_TEST_SUITE(TTypeTraitsTestNg) {
+Y_UNIT_TEST_SUITE(TTypeTraitsTestNg) {
template <typename T>
void TestImpl() {
//UNIT_ASSERT_EQUAL_ENUM(TTypeTraitsExpected<T>::IsPod, TTypeTraits<T>::IsPod);
@@ -434,22 +434,22 @@ enum class E8: ui8 {
X
};
-// test for std::underlying_type_t
-static_assert(sizeof(std::underlying_type_t<E4>) == sizeof(int), "");
-static_assert(sizeof(std::underlying_type_t<E64>) == sizeof(ui64), "");
-static_assert(sizeof(std::underlying_type_t<E8>) == sizeof(ui8), "");
-
-// tests for TFixedWidthUnsignedInt
-static_assert(std::is_same<ui8, TFixedWidthUnsignedInt<i8>>::value, "");
-static_assert(std::is_same<ui16, TFixedWidthUnsignedInt<i16>>::value, "");
-static_assert(std::is_same<ui32, TFixedWidthUnsignedInt<i32>>::value, "");
-static_assert(std::is_same<ui64, TFixedWidthUnsignedInt<i64>>::value, "");
-
-// tests for TFixedWidthSignedInt
-static_assert(std::is_same<i8, TFixedWidthSignedInt<ui8>>::value, "");
-static_assert(std::is_same<i16, TFixedWidthSignedInt<ui16>>::value, "");
-static_assert(std::is_same<i32, TFixedWidthSignedInt<ui32>>::value, "");
-static_assert(std::is_same<i64, TFixedWidthSignedInt<ui64>>::value, "");
+// test for std::underlying_type_t
+static_assert(sizeof(std::underlying_type_t<E4>) == sizeof(int), "");
+static_assert(sizeof(std::underlying_type_t<E64>) == sizeof(ui64), "");
+static_assert(sizeof(std::underlying_type_t<E8>) == sizeof(ui8), "");
+
+// tests for TFixedWidthUnsignedInt
+static_assert(std::is_same<ui8, TFixedWidthUnsignedInt<i8>>::value, "");
+static_assert(std::is_same<ui16, TFixedWidthUnsignedInt<i16>>::value, "");
+static_assert(std::is_same<ui32, TFixedWidthUnsignedInt<i32>>::value, "");
+static_assert(std::is_same<ui64, TFixedWidthUnsignedInt<i64>>::value, "");
+
+// tests for TFixedWidthSignedInt
+static_assert(std::is_same<i8, TFixedWidthSignedInt<ui8>>::value, "");
+static_assert(std::is_same<i16, TFixedWidthSignedInt<ui16>>::value, "");
+static_assert(std::is_same<i32, TFixedWidthSignedInt<ui32>>::value, "");
+static_assert(std::is_same<i64, TFixedWidthSignedInt<ui64>>::value, "");
// test for TIsSpecializationOf
static_assert(TIsSpecializationOf<std::vector, std::vector<int>>::value, "");
diff --git a/util/generic/ut/ya.make b/util/generic/ut/ya.make
index fbe31ffc32..6eaf24cc5f 100644
--- a/util/generic/ut/ya.make
+++ b/util/generic/ut/ya.make
@@ -58,16 +58,16 @@ SRCS(
INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc)
-IF (NOT OS_IOS AND NOT ARCH_PPC64LE)
- # Abseil fails to build (with linkage error) on ios and with compilation error on PowerPC
- # (somewhere in unscaledcycleclock.cc).
- PEERDIR(
+IF (NOT OS_IOS AND NOT ARCH_PPC64LE)
+ # Abseil fails to build (with linkage error) on ios and with compilation error on PowerPC
+ # (somewhere in unscaledcycleclock.cc).
+ PEERDIR(
library/cpp/containers/absl_flat_hash
- )
-
- SRCS(
- generic/string_transparent_hash_ut.cpp
- )
-ENDIF()
-
+ )
+
+ SRCS(
+ generic/string_transparent_hash_ut.cpp
+ )
+ENDIF()
+
END()
diff --git a/util/generic/utility.h b/util/generic/utility.h
index 0deda97bb7..43b98eeafc 100644
--- a/util/generic/utility.h
+++ b/util/generic/utility.h
@@ -66,8 +66,8 @@ static inline void SecureZero(T& t) noexcept {
}
namespace NSwapCheck {
- Y_HAS_MEMBER(swap);
- Y_HAS_MEMBER(Swap);
+ Y_HAS_MEMBER(swap);
+ Y_HAS_MEMBER(Swap);
template <class T, class = void>
struct TSwapSelector {
diff --git a/util/generic/va_args.cpp b/util/generic/va_args.cpp
index 6b66aec5a4..2266d05a0d 100644
--- a/util/generic/va_args.cpp
+++ b/util/generic/va_args.cpp
@@ -2,14 +2,14 @@
// Test that it compiles
#define __DUMMY__(x)
-Y_MAP_ARGS(__DUMMY__, 1, 2, 3);
+Y_MAP_ARGS(__DUMMY__, 1, 2, 3);
#define __DUMMY_LAST__(x)
-Y_MAP_ARGS_WITH_LAST(__DUMMY__, __DUMMY_LAST__, 1, 2, 3);
+Y_MAP_ARGS_WITH_LAST(__DUMMY__, __DUMMY_LAST__, 1, 2, 3);
#undef __DUMMY_LAST__
#undef __DUMMY__
#define __MULTI_DUMMY__(x, y)
#define __MULTI_DUMMY_PROXY__(x) __MULTI_DUMMY__ x
-Y_MAP_ARGS(__MULTI_DUMMY_PROXY__, (1, 2), (3, 4));
+Y_MAP_ARGS(__MULTI_DUMMY_PROXY__, (1, 2), (3, 4));
#undef __MULTI_DUMMY_PROXY__
#undef __MULTI_DUMMY__
diff --git a/util/generic/va_args.h b/util/generic/va_args.h
index 90eb5c17ad..33498d47ed 100644
--- a/util/generic/va_args.h
+++ b/util/generic/va_args.h
@@ -16,7 +16,7 @@
* Used merely for working around an MSVC++ bug.
* See http://stackoverflow.com/questions/5134523/msvc-doesnt-expand-va-args-correctly
*/
-#define Y_PASS_VA_ARGS(x) x
+#define Y_PASS_VA_ARGS(x) x
/**
* Count number of arguments in `__VA_ARGS__`.
@@ -768,16 +768,16 @@
/**
* Macros for implementing overload by number of arguments.
- *
+ *
* Example usage:
- *
+ *
* @code{cpp}
* #define I1(arg1) Cout << Y_STRINGIZE(arg1) << Endl;
* #define I2(arg1, arg2) Cout << Y_STRINGIZE(arg1) << ';' << Y_STRINGIZE(arg2) << Endl;
- *
+ *
* #define Y_PRINT(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, I2, I1)(__VA_ARGS__))
- * @endcode
- */
+ * @endcode
+ */
/// @{
#define Y_MACRO_IMPL_DISPATCHER_2(_0, _1, IMPL, ...) IMPL
#define Y_MACRO_IMPL_DISPATCHER_3(_0, _1, _2, IMPL, ...) IMPL
diff --git a/util/generic/va_args_gen.py b/util/generic/va_args_gen.py
index 2dc5346f56..232b53fca6 100755
--- a/util/generic/va_args_gen.py
+++ b/util/generic/va_args_gen.py
@@ -65,7 +65,7 @@ def count(limit):
print('#define Y_COUNT_ARGS(...) Y_PASS_VA_ARGS('
'__Y_COUNT_ARGS(__VA_ARGS__, {}))'.format(numbers))
print('#define __Y_COUNT_ARGS({}, N, ...) N'.format(u_numbers))
-
+
def get_elem(limit):
print(textwrap.dedent('''
diff --git a/util/generic/va_args_ut.cpp b/util/generic/va_args_ut.cpp
index b07109095c..a9c96a0f55 100644
--- a/util/generic/va_args_ut.cpp
+++ b/util/generic/va_args_ut.cpp
@@ -2,16 +2,16 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TMacroVarargMapTest) {
- Y_UNIT_TEST(TestMapArgs) {
- static const char COMBINED[] = Y_MAP_ARGS(Y_STRINGIZE, 1, 2, 3);
+Y_UNIT_TEST_SUITE(TMacroVarargMapTest) {
+ Y_UNIT_TEST(TestMapArgs) {
+ static const char COMBINED[] = Y_MAP_ARGS(Y_STRINGIZE, 1, 2, 3);
UNIT_ASSERT_STRINGS_EQUAL(COMBINED, "123");
}
- Y_UNIT_TEST(TestMapArgsWithLast) {
+ Y_UNIT_TEST(TestMapArgsWithLast) {
#define ADD(x) x +
#define ID(x) x
- static const int SUM = Y_MAP_ARGS_WITH_LAST(ADD, ID, 1, 2, 3, 4 + 5);
+ static const int SUM = Y_MAP_ARGS_WITH_LAST(ADD, ID, 1, 2, 3, 4 + 5);
UNIT_ASSERT_VALUES_EQUAL(SUM, 1 + 2 + 3 + 4 + 5);
#undef ADD
#undef ID
diff --git a/util/generic/vector_ut.cpp b/util/generic/vector_ut.cpp
index 19475a78ef..0f6b4037a0 100644
--- a/util/generic/vector_ut.cpp
+++ b/util/generic/vector_ut.cpp
@@ -566,7 +566,7 @@ private:
void CheckInitializeList(const TVector<int>& v) {
for (size_t i = 0; i < v.size(); ++i) {
- UNIT_ASSERT_EQUAL(v[i], static_cast<int>(i));
+ UNIT_ASSERT_EQUAL(v[i], static_cast<int>(i));
}
}
diff --git a/util/generic/xrange.h b/util/generic/xrange.h
index 6d1b86eb44..5fc8c82912 100644
--- a/util/generic/xrange.h
+++ b/util/generic/xrange.h
@@ -24,7 +24,7 @@ namespace NPrivate {
using TDiff = decltype(T() - T());
public:
- constexpr TSimpleXRange(T start, T finish) noexcept
+ constexpr TSimpleXRange(T start, T finish) noexcept
: Start(start)
, Finish(Max(start, finish))
{
@@ -38,20 +38,20 @@ namespace NPrivate {
using reference = const T&;
using iterator_category = std::random_access_iterator_tag;
- constexpr TIterator(T value) noexcept
+ constexpr TIterator(T value) noexcept
: Value(value)
{
}
- constexpr T operator*() const noexcept {
+ constexpr T operator*() const noexcept {
return Value;
}
- constexpr bool operator!=(const TIterator& other) const noexcept {
+ constexpr bool operator!=(const TIterator& other) const noexcept {
return Value != other.Value;
}
- constexpr bool operator==(const TIterator& other) const noexcept {
+ constexpr bool operator==(const TIterator& other) const noexcept {
return Value == other.Value;
}
@@ -65,23 +65,23 @@ namespace NPrivate {
return *this;
}
- constexpr TDiff operator-(const TIterator& b) const noexcept {
+ constexpr TDiff operator-(const TIterator& b) const noexcept {
return Value - b.Value;
}
template <typename IntType>
- constexpr TIterator operator+(const IntType& b) const noexcept {
+ constexpr TIterator operator+(const IntType& b) const noexcept {
return TIterator(Value + b);
}
template <typename IntType>
- TIterator& operator+=(const IntType& b) noexcept {
+ TIterator& operator+=(const IntType& b) noexcept {
Value += b;
return *this;
}
template <typename IntType>
- constexpr TIterator operator-(const IntType& b) const noexcept {
+ constexpr TIterator operator-(const IntType& b) const noexcept {
return TIterator(Value - b);
}
@@ -103,15 +103,15 @@ namespace NPrivate {
using iterator = TIterator;
using const_iterator = TIterator;
- constexpr TIterator begin() const noexcept {
+ constexpr TIterator begin() const noexcept {
return TIterator(Start);
}
- constexpr TIterator end() const noexcept {
+ constexpr TIterator end() const noexcept {
return TIterator(Finish);
}
- constexpr T size() const noexcept {
+ constexpr T size() const noexcept {
return Finish - Start;
}
@@ -130,7 +130,7 @@ namespace NPrivate {
using TDiff = decltype(T() - T());
public:
- constexpr TSteppedXRange(T start, T finish, TDiff step) noexcept
+ constexpr TSteppedXRange(T start, T finish, TDiff step) noexcept
: Start_(start)
, Step_(step)
, Finish_(CalcRealFinish(Start_, finish, Step_))
@@ -146,21 +146,21 @@ namespace NPrivate {
using reference = const T&;
using iterator_category = std::random_access_iterator_tag;
- constexpr TIterator(T value, const TSteppedXRange& parent) noexcept
+ constexpr TIterator(T value, const TSteppedXRange& parent) noexcept
: Value_(value)
, Parent_(&parent)
{
}
- constexpr T operator*() const noexcept {
+ constexpr T operator*() const noexcept {
return Value_;
}
- constexpr bool operator!=(const TIterator& other) const noexcept {
+ constexpr bool operator!=(const TIterator& other) const noexcept {
return Value_ != other.Value_;
}
- constexpr bool operator==(const TIterator& other) const noexcept {
+ constexpr bool operator==(const TIterator& other) const noexcept {
return Value_ == other.Value_;
}
@@ -174,23 +174,23 @@ namespace NPrivate {
return *this;
}
- constexpr TDiff operator-(const TIterator& b) const noexcept {
+ constexpr TDiff operator-(const TIterator& b) const noexcept {
return (Value_ - b.Value_) / Parent_->Step_;
}
template <typename IntType>
- constexpr TIterator operator+(const IntType& b) const noexcept {
+ constexpr TIterator operator+(const IntType& b) const noexcept {
return TIterator(*this) += b;
}
template <typename IntType>
- TIterator& operator+=(const IntType& b) noexcept {
+ TIterator& operator+=(const IntType& b) noexcept {
Value_ += b * Parent_->Step_;
return *this;
}
template <typename IntType>
- constexpr TIterator operator-(const IntType& b) const noexcept {
+ constexpr TIterator operator-(const IntType& b) const noexcept {
return TIterator(*this) -= b;
}
@@ -209,16 +209,16 @@ namespace NPrivate {
using iterator = TIterator;
using const_iterator = TIterator;
- constexpr TIterator begin() const noexcept {
+ constexpr TIterator begin() const noexcept {
return TIterator(Start_, *this);
}
- constexpr TIterator end() const noexcept {
+ constexpr TIterator end() const noexcept {
return TIterator(Finish_, *this);
}
static T CalcRealFinish(T start, T expFinish, TDiff step) {
- Y_ASSERT(step != 0);
+ Y_ASSERT(step != 0);
if (step > 0) {
if (expFinish > start) {
return start + step * ((expFinish - 1 - start) / step + 1);
@@ -228,7 +228,7 @@ namespace NPrivate {
return start - TSteppedXRange<TDiff>::CalcRealFinish(0, start - expFinish, -step);
}
- constexpr T size() const noexcept {
+ constexpr T size() const noexcept {
return (Finish_ - Start_) / Step_;
}
@@ -251,18 +251,18 @@ namespace NPrivate {
* @param step must be non-zero
*/
template <typename T>
-constexpr ::NPrivate::TSteppedXRange<T> xrange(T start, T finish, decltype(T() - T()) step) noexcept {
+constexpr ::NPrivate::TSteppedXRange<T> xrange(T start, T finish, decltype(T() - T()) step) noexcept {
return {start, finish, step};
}
/// generate sequence [start; finish)
template <typename T>
-constexpr ::NPrivate::TSimpleXRange<T> xrange(T start, T finish) noexcept {
+constexpr ::NPrivate::TSimpleXRange<T> xrange(T start, T finish) noexcept {
return {start, finish};
}
/// generate sequence [0; finish)
template <typename T>
-constexpr auto xrange(T finish) noexcept -> decltype(xrange(T(), finish)) {
+constexpr auto xrange(T finish) noexcept -> decltype(xrange(T(), finish)) {
return xrange(T(), finish);
}
diff --git a/util/generic/xrange_ut.cpp b/util/generic/xrange_ut.cpp
index d0a43637cf..8106da03e7 100644
--- a/util/generic/xrange_ut.cpp
+++ b/util/generic/xrange_ut.cpp
@@ -6,7 +6,7 @@
#include <library/cpp/testing/unittest/registar.h>
#include <util/string/builder.h>
-Y_UNIT_TEST_SUITE(XRange) {
+Y_UNIT_TEST_SUITE(XRange) {
void TestXRangeImpl(size_t begin, size_t end) {
size_t count = 0;
size_t sum = 0;
@@ -40,18 +40,18 @@ Y_UNIT_TEST_SUITE(XRange) {
UNIT_ASSERT_VALUES_EQUAL(expInd, expected.size());
}
- Y_UNIT_TEST(IncrementWorks) {
+ Y_UNIT_TEST(IncrementWorks) {
TestXRangeImpl(0, 10);
TestXRangeImpl(10, 20);
}
- Y_UNIT_TEST(DecrementWorks) {
+ Y_UNIT_TEST(DecrementWorks) {
TestSteppedXRangeImpl(10, 0, -1, {10, 9, 8, 7, 6, 5, 4, 3, 2, 1});
TestSteppedXRangeImpl(10, -1, -1, {10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0});
TestSteppedXRangeImpl(20, 9, -1, {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10});
}
- Y_UNIT_TEST(StepWorks) {
+ Y_UNIT_TEST(StepWorks) {
TestSteppedXRangeImpl(0, 0, 1, {});
TestSteppedXRangeImpl(0, 9, 3, {0, 3, 6});
TestSteppedXRangeImpl(0, 10, 3, {0, 3, 6, 9});
@@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(XRange) {
TestSteppedXRangeImpl(15, -2, -4, {15, 11, 7, 3, -1});
}
- Y_UNIT_TEST(PointersWorks) {
+ Y_UNIT_TEST(PointersWorks) {
TVector<size_t> data = {3, 1, 4, 1, 5, 9, 2, 6};
const size_t digSumExpected = Accumulate(data.begin(), data.end(), static_cast<size_t>(0));
size_t digSumByIt = 0;
@@ -79,7 +79,7 @@ Y_UNIT_TEST_SUITE(XRange) {
UNIT_ASSERT_VALUES_EQUAL(digSumByPtr, digSumExpected);
}
- Y_UNIT_TEST(SizeMethodCheck) {
+ Y_UNIT_TEST(SizeMethodCheck) {
UNIT_ASSERT_VALUES_EQUAL(xrange(5).size(), 5);
UNIT_ASSERT_VALUES_EQUAL(xrange(0, 5, 2).size(), 3);
UNIT_ASSERT_VALUES_EQUAL(xrange(0, 6, 2).size(), 3);
@@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(XRange) {
}
};
- Y_UNIT_TEST(ConvertionWorks) {
+ Y_UNIT_TEST(ConvertionWorks) {
TVector<size_t> data = {0, 1, 2, 3, 4, 5, 6, 7, 8};
TVector<size_t> convertionResults[] = {xrange<size_t>(9),
@@ -119,7 +119,7 @@ Y_UNIT_TEST_SUITE(XRange) {
UNIT_ASSERT_VALUES_EQUAL(emptyRange.size(), 0);
for (auto i : emptyRange) {
- Y_UNUSED(i);
+ Y_UNUSED(i);
UNIT_ASSERT(false);
}
@@ -129,7 +129,7 @@ Y_UNIT_TEST_SUITE(XRange) {
}
}
- Y_UNIT_TEST(EmptySimpleRange) {
+ Y_UNIT_TEST(EmptySimpleRange) {
using TSimpleRange = decltype(xrange(1));
const TSimpleRange emptySimpleRanges[] = {
@@ -143,7 +143,7 @@ Y_UNIT_TEST_SUITE(XRange) {
TestEmptyRanges(emptySimpleRanges);
}
- Y_UNIT_TEST(EmptySteppedRange) {
+ Y_UNIT_TEST(EmptySteppedRange) {
using TSteppedRange = decltype(xrange(1, 10, 1));
const TSteppedRange emptySteppedRanges[] = {
diff --git a/util/generic/yexception.cpp b/util/generic/yexception.cpp
index 630aaa42e2..2ce6c4369d 100644
--- a/util/generic/yexception.cpp
+++ b/util/generic/yexception.cpp
@@ -75,22 +75,22 @@ void TSystemError::Init() {
exc << TStringBuf(") ");
}
-NPrivateException::yexception::yexception() {
- ZeroTerminate();
-}
-
-TStringBuf NPrivateException::yexception::AsStrBuf() const {
- if (Buf_.Left()) {
- return TStringBuf(Buf_.Data(), Buf_.Filled());
- }
-
- return TStringBuf(Buf_.Data(), Buf_.Filled() - 1);
-}
-
-void NPrivateException::yexception::ZeroTerminate() noexcept {
- char* end = (char*)Buf_.Current();
-
- if (!Buf_.Left()) {
+NPrivateException::yexception::yexception() {
+ ZeroTerminate();
+}
+
+TStringBuf NPrivateException::yexception::AsStrBuf() const {
+ if (Buf_.Left()) {
+ return TStringBuf(Buf_.Data(), Buf_.Filled());
+ }
+
+ return TStringBuf(Buf_.Data(), Buf_.Filled() - 1);
+}
+
+void NPrivateException::yexception::ZeroTerminate() noexcept {
+ char* end = (char*)Buf_.Current();
+
+ if (!Buf_.Left()) {
--end;
}
@@ -98,11 +98,11 @@ void NPrivateException::yexception::ZeroTerminate() noexcept {
}
const char* NPrivateException::yexception::what() const noexcept {
- return Buf_.Data();
+ return Buf_.Data();
}
const TBackTrace* NPrivateException::yexception::BackTrace() const noexcept {
- return nullptr;
+ return nullptr;
}
void fputs(const std::exception& e, FILE* f) {
diff --git a/util/generic/yexception.h b/util/generic/yexception.h
index 49917a342b..b0c604e8c4 100644
--- a/util/generic/yexception.h
+++ b/util/generic/yexception.h
@@ -4,13 +4,13 @@
#include "strbuf.h"
#include "string.h"
#include "utility.h"
-#include "va_args.h"
+#include "va_args.h"
#include <utility>
-#include <util/stream/tempbuf.h>
-#include <util/system/compat.h>
-#include <util/system/compiler.h>
-#include <util/system/defaults.h>
+#include <util/stream/tempbuf.h>
+#include <util/system/compat.h>
+#include <util/system/compiler.h>
+#include <util/system/defaults.h>
#include <util/system/error.h>
#include <util/system/src_location.h>
#include <util/system/platform.h>
@@ -39,30 +39,30 @@ namespace NPrivateException {
class yexception: public std::exception {
public:
- yexception();
- yexception(const yexception&) = default;
- yexception(yexception&&) = default;
-
- yexception& operator=(const yexception&) = default;
- yexception& operator=(yexception&&) = default;
-
+ yexception();
+ yexception(const yexception&) = default;
+ yexception(yexception&&) = default;
+
+ yexception& operator=(const yexception&) = default;
+ yexception& operator=(yexception&&) = default;
+
const char* what() const noexcept override;
virtual const TBackTrace* BackTrace() const noexcept;
template <class T>
inline void Append(const T& t) {
TTempBufCuttingWrapperOutput tempBuf(Buf_);
- static_cast<IOutputStream&>(tempBuf) << t;
- ZeroTerminate();
+ static_cast<IOutputStream&>(tempBuf) << t;
+ ZeroTerminate();
}
- TStringBuf AsStrBuf() const;
+ TStringBuf AsStrBuf() const;
+
+ private:
+ void ZeroTerminate() noexcept;
private:
- void ZeroTerminate() noexcept;
-
- private:
- TTempBuf Buf_;
+ TTempBuf Buf_;
};
template <class E, class T>
@@ -82,7 +82,7 @@ namespace NPrivateException {
class yexception: public NPrivateException::yexception {
};
-Y_DECLARE_OUT_SPEC(inline, yexception, stream, value) {
+Y_DECLARE_OUT_SPEC(inline, yexception, stream, value) {
stream << value.AsStrBuf();
}
@@ -175,13 +175,13 @@ std::string CurrentExceptionTypeName();
TString FormatExc(const std::exception& exception);
-#define Y_ENSURE_EX(CONDITION, THROW_EXPRESSION) \
- do { \
- if (Y_UNLIKELY(!(CONDITION))) { \
- ythrow THROW_EXPRESSION; \
- } \
+#define Y_ENSURE_EX(CONDITION, THROW_EXPRESSION) \
+ do { \
+ if (Y_UNLIKELY(!(CONDITION))) { \
+ ythrow THROW_EXPRESSION; \
+ } \
} while (false)
-
+
/// @def Y_ENSURE_SIMPLE
/// This macro works like the Y_ENSURE, but requires the second argument to be a constant string view.
/// Should not be used directly.
@@ -195,25 +195,25 @@ TString FormatExc(const std::exception& exception);
} while (false)
#define Y_ENSURE_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYException)
-#define Y_ENSURE_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, yexception() << MESSAGE)
-
+#define Y_ENSURE_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, yexception() << MESSAGE)
+
#define Y_ENSURE_BT_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYExceptionWithBacktrace)
#define Y_ENSURE_BT_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, TWithBackTrace<yexception>() << MESSAGE)
-/**
- * @def Y_ENSURE
- *
- * This macro is inteded to use as a shortcut for `if () { throw }`.
- *
- * @code
- * void DoSomethingLovely(const int x, const int y) {
- * Y_ENSURE(x > y, "`x` must be greater than `y`");
- * Y_ENSURE(x > y); // if you are too lazy
- * // actually doing something nice here
- * }
- * @endcode
- */
-#define Y_ENSURE(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_ENSURE_IMPL_2, Y_ENSURE_IMPL_1)(__VA_ARGS__))
+/**
+ * @def Y_ENSURE
+ *
+ * This macro is inteded to use as a shortcut for `if () { throw }`.
+ *
+ * @code
+ * void DoSomethingLovely(const int x, const int y) {
+ * Y_ENSURE(x > y, "`x` must be greater than `y`");
+ * Y_ENSURE(x > y); // if you are too lazy
+ * // actually doing something nice here
+ * }
+ * @endcode
+ */
+#define Y_ENSURE(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_ENSURE_IMPL_2, Y_ENSURE_IMPL_1)(__VA_ARGS__))
/**
* @def Y_ENSURE_BT
diff --git a/util/generic/yexception_ut.cpp b/util/generic/yexception_ut.cpp
index 81fb0f19da..cb3e29fed8 100644
--- a/util/generic/yexception_ut.cpp
+++ b/util/generic/yexception_ut.cpp
@@ -13,7 +13,7 @@ static inline void Throw2DontMove() {
#include <util/generic/algorithm.h>
#include <util/memory/tempbuf.h>
#include <util/random/mersenne.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/string/subst.h>
#include "yexception_ut.h"
@@ -27,7 +27,7 @@ static void CallbackFun(int i) {
throw i;
}
-static IOutputStream* OUTS = nullptr;
+static IOutputStream* OUTS = nullptr;
namespace NOuter::NInner {
void Compare10And20() {
@@ -49,7 +49,7 @@ class TExceptionTest: public TTestBase {
UNIT_TEST(TestEnsureWithBackTrace1)
UNIT_TEST(TestEnsureWithBackTrace2)
UNIT_TEST(TestRethrowAppend)
- UNIT_TEST(TestMacroOverload)
+ UNIT_TEST(TestMacroOverload)
UNIT_TEST(TestMessageCrop)
UNIT_TEST(TestTIoSystemErrorSpecialMethods)
UNIT_TEST(TestCurrentExceptionTypeNameMethod)
@@ -260,26 +260,26 @@ private:
UNIT_ASSERT_VALUES_EQUAL(i, N);
}
}
-
- void TestMacroOverload() {
- try {
- Y_ENSURE(10 > 20);
- } catch (const yexception& e) {
- UNIT_ASSERT(e.AsStrBuf().Contains("10 > 20"));
- }
-
- try {
- Y_ENSURE(10 > 20, "exception message to search for");
- } catch (const yexception& e) {
- UNIT_ASSERT(e.AsStrBuf().Contains("exception message to search for"));
- }
+
+ void TestMacroOverload() {
+ try {
+ Y_ENSURE(10 > 20);
+ } catch (const yexception& e) {
+ UNIT_ASSERT(e.AsStrBuf().Contains("10 > 20"));
+ }
+
+ try {
+ Y_ENSURE(10 > 20, "exception message to search for");
+ } catch (const yexception& e) {
+ UNIT_ASSERT(e.AsStrBuf().Contains("exception message to search for"));
+ }
try {
NOuter::NInner::Compare10And20();
} catch (const yexception& e) {
UNIT_ASSERT(e.AsStrBuf().Contains("10 > 20"));
}
- }
+ }
void TestMessageCrop() {
TTempBuf tmp;
@@ -293,7 +293,7 @@ private:
}
yexception e;
e << s;
- UNIT_ASSERT_EQUAL(e.AsStrBuf(), s.substr(0, tmp.Size() - 1));
+ UNIT_ASSERT_EQUAL(e.AsStrBuf(), s.substr(0, tmp.Size() - 1));
}
}
diff --git a/util/generic/ylimits.h b/util/generic/ylimits.h
index f6964b8a6a..fe42b4dfc0 100644
--- a/util/generic/ylimits.h
+++ b/util/generic/ylimits.h
@@ -8,12 +8,12 @@
template <class T>
static constexpr T Max() noexcept {
- return std::numeric_limits<T>::max();
+ return std::numeric_limits<T>::max();
}
template <class T>
static constexpr T Min() noexcept {
- return std::numeric_limits<T>::min();
+ return std::numeric_limits<T>::min();
}
namespace NPrivate {
diff --git a/util/generic/ylimits_ut.cpp b/util/generic/ylimits_ut.cpp
index 60dc5c5390..f1b3c6858c 100644
--- a/util/generic/ylimits_ut.cpp
+++ b/util/generic/ylimits_ut.cpp
@@ -34,7 +34,7 @@ static inline bool ValidSignInfo(bool limitIsSigned, const T&) {
template <class T>
static inline bool TestIntegralLimits(const T&, bool unknownSign = true, bool isSigned = true) {
- using lim = std::numeric_limits<T>;
+ using lim = std::numeric_limits<T>;
CHECK_COND(lim::is_specialized);
CHECK_COND(lim::is_integer);
@@ -66,7 +66,7 @@ static inline bool TestUnsignedIntegralLimits(const T& val) {
template <class T>
static inline bool TestFloatLimits(const T&) {
- using lim = std::numeric_limits<T>;
+ using lim = std::numeric_limits<T>;
CHECK_COND(lim::is_specialized);
CHECK_COND(!lim::is_modulo);
@@ -96,7 +96,7 @@ static inline bool TestFloatLimits(const T&) {
template <class T>
static inline bool TestNan(const T&) {
- using lim = std::numeric_limits<T>;
+ using lim = std::numeric_limits<T>;
if (lim::has_quiet_NaN) {
const T qnan = lim::quiet_NaN();
diff --git a/util/generic/ymath.cpp b/util/generic/ymath.cpp
index c7dfc0260a..31270728f4 100644
--- a/util/generic/ymath.cpp
+++ b/util/generic/ymath.cpp
@@ -11,8 +11,8 @@ float Exp2f(float x) {
#ifdef _MSC_VER
double Erf(double x) {
- static constexpr double _M_2_SQRTPI = 1.12837916709551257390;
- static constexpr double eps = 1.0e-7;
+ static constexpr double _M_2_SQRTPI = 1.12837916709551257390;
+ static constexpr double eps = 1.0e-7;
if (fabs(x) >= 3.75)
return x > 0 ? 1.0 : -1.0;
double r = _M_2_SQRTPI * x;
@@ -29,12 +29,12 @@ double Erf(double x) {
#endif // _MSC_VER
double LogGammaImpl(double x) {
- static constexpr double lnSqrt2Pi = 0.91893853320467274178; // log(sqrt(2.0 * PI))
- static constexpr double coeff9 = 1.0 / 1188.0;
- static constexpr double coeff7 = -1.0 / 1680.0;
- static constexpr double coeff5 = 1.0 / 1260.0;
- static constexpr double coeff3 = -1.0 / 360.0;
- static constexpr double coeff1 = 1.0 / 12.0;
+ static constexpr double lnSqrt2Pi = 0.91893853320467274178; // log(sqrt(2.0 * PI))
+ static constexpr double coeff9 = 1.0 / 1188.0;
+ static constexpr double coeff7 = -1.0 / 1680.0;
+ static constexpr double coeff5 = 1.0 / 1260.0;
+ static constexpr double coeff3 = -1.0 / 360.0;
+ static constexpr double coeff1 = 1.0 / 12.0;
if ((x == 1.0) || (x == 2.0)) {
return 0.0; // 0! = 1
diff --git a/util/generic/ymath.h b/util/generic/ymath.h
index 5fe17e2608..9ff9ae2abe 100644
--- a/util/generic/ymath.h
+++ b/util/generic/ymath.h
@@ -10,9 +10,9 @@
#include "typetraits.h"
#include "utility.h"
-constexpr double PI = M_PI;
-constexpr double M_LOG2_10 = 3.32192809488736234787; // log2(10)
-constexpr double M_LN2_INV = M_LOG2E; // 1 / ln(2) == log2(e)
+constexpr double PI = M_PI;
+constexpr double M_LOG2_10 = 3.32192809488736234787; // log2(10)
+constexpr double M_LN2_INV = M_LOG2E; // 1 / ln(2) == log2(e)
/**
* \returns Absolute value of the provided argument.
@@ -42,7 +42,7 @@ inline float Log2(float value) {
* @returns Base 2 logarithm of the provided integral value.
*/
template <class T>
-inline std::enable_if_t<std::is_integral<T>::value, double>
+inline std::enable_if_t<std::is_integral<T>::value, double>
Log2(T value) {
return Log2(static_cast<double>(value));
}
@@ -52,7 +52,7 @@ double Exp2(double);
float Exp2f(float);
template <class T>
-static constexpr T Sqr(const T t) noexcept {
+static constexpr T Sqr(const T t) noexcept {
return t * t;
}
diff --git a/util/generic/ymath_ut.cpp b/util/generic/ymath_ut.cpp
index cf4f7cd5f7..29190b55eb 100644
--- a/util/generic/ymath_ut.cpp
+++ b/util/generic/ymath_ut.cpp
@@ -3,14 +3,14 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/datetime/cputimer.h>
#include <limits>
template <class T>
static inline T SlowClp2(T t) noexcept {
- Y_ASSERT(t > 0);
+ Y_ASSERT(t > 0);
T ret = 1;
diff --git a/util/memory/blob.cpp b/util/memory/blob.cpp
index e9936c2bcb..91da5cadca 100644
--- a/util/memory/blob.cpp
+++ b/util/memory/blob.cpp
@@ -4,7 +4,7 @@
#include <util/system/yassert.h>
#include <util/system/filemap.h>
#include <util/system/mlock.h>
-#include <util/stream/buffer.h>
+#include <util/stream/buffer.h>
#include <util/generic/ptr.h>
#include <util/generic/string.h>
#include <util/generic/buffer.h>
@@ -174,7 +174,7 @@ static inline TBlob CopyConstruct(const void* data, size_t len) {
using Base = TDynamicBlobBase<TCounter>;
THolder<Base> base(new (len) Base);
- Y_ASSERT(base->Length() == len);
+ Y_ASSERT(base->Length() == len);
memcpy(base->Data(), data, len);
@@ -305,7 +305,7 @@ static inline TBlob ReadFromFile(const TFile& file, ui64 offset, size_t length)
using TBase = TDynamicBlobBase<TCounter>;
THolder<TBase> base(new (length) TBase);
- Y_ASSERT(base->Length() == length);
+ Y_ASSERT(base->Length() == length);
file.Pload(base->Data(), length, offset);
@@ -362,7 +362,7 @@ static inline TBlob ConstructFromBuffer(TBuffer& in) {
}
template <class TCounter>
-static inline TBlob ConstructFromStream(IInputStream& in) {
+static inline TBlob ConstructFromStream(IInputStream& in) {
TBuffer buf;
{
@@ -374,11 +374,11 @@ static inline TBlob ConstructFromStream(IInputStream& in) {
return ConstructFromBuffer<TCounter>(buf);
}
-TBlob TBlob::FromStreamSingleThreaded(IInputStream& in) {
+TBlob TBlob::FromStreamSingleThreaded(IInputStream& in) {
return ConstructFromStream<TSimpleCounter>(in);
}
-TBlob TBlob::FromStream(IInputStream& in) {
+TBlob TBlob::FromStream(IInputStream& in) {
return ConstructFromStream<TAtomicCounter>(in);
}
diff --git a/util/memory/blob.h b/util/memory/blob.h
index b5a610bce8..20c02a68df 100644
--- a/util/memory/blob.h
+++ b/util/memory/blob.h
@@ -6,7 +6,7 @@
#include <util/system/defaults.h>
class TMemoryMap;
-class IInputStream;
+class IInputStream;
class TFile;
class TBuffer;
@@ -281,10 +281,10 @@ public:
static TBlob FromFileContent(const TFile& file, ui64 offset, size_t length);
/// Creates a blob from the stream content with a single-threaded (non atomic) refcounter.
- static TBlob FromStreamSingleThreaded(IInputStream& in);
+ static TBlob FromStreamSingleThreaded(IInputStream& in);
/// Creates a blob from the stream content with a multi-threaded (atomic) refcounter.
- static TBlob FromStream(IInputStream& in);
+ static TBlob FromStream(IInputStream& in);
/// Creates a blob with a single-threaded (non atomic) refcounter. No memory allocation, no content copy.
/// @details The input object becomes empty.
diff --git a/util/memory/blob_ut.cpp b/util/memory/blob_ut.cpp
index d5b14b8672..023f9a0487 100644
--- a/util/memory/blob_ut.cpp
+++ b/util/memory/blob_ut.cpp
@@ -4,7 +4,7 @@
#include <util/system/tempfile.h>
#include <util/folder/path.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/stream/file.h>
#include <util/generic/buffer.h>
#include <util/generic/array_ref.h>
diff --git a/util/memory/pool.h b/util/memory/pool.h
index 0de5467701..13c8b6b9ed 100644
--- a/util/memory/pool.h
+++ b/util/memory/pool.h
@@ -33,7 +33,7 @@ private:
: Cur_((char*)(this + 1))
, Left_(len)
{
- Y_ASSERT((((size_t)Cur_) % PLATFORM_DATA_ALIGN) == 0);
+ Y_ASSERT((((size_t)Cur_) % PLATFORM_DATA_ALIGN) == 0);
}
inline void* Allocate(size_t len) noexcept {
@@ -46,7 +46,7 @@ private:
return ret;
}
- return nullptr;
+ return nullptr;
}
inline void* Allocate(size_t len, size_t align) noexcept {
@@ -57,7 +57,7 @@ private:
return static_cast<char*>(ret) + pad;
}
- return nullptr;
+ return nullptr;
}
inline size_t BlockLength() const noexcept {
diff --git a/util/memory/pool_ut.cpp b/util/memory/pool_ut.cpp
index dd79864f72..1158a8ca42 100644
--- a/util/memory/pool_ut.cpp
+++ b/util/memory/pool_ut.cpp
@@ -2,7 +2,7 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
class TCheckedAllocator: public TDefaultAllocator {
public:
diff --git a/util/memory/segmented_string_pool.h b/util/memory/segmented_string_pool.h
index ecc3ca3c1a..a40aa408f5 100644
--- a/util/memory/segmented_string_pool.h
+++ b/util/memory/segmented_string_pool.h
@@ -23,7 +23,7 @@ protected:
size_t _size; // size of allocated chunk in sizeof(T)-units
size_t freepos; // offset to free chunk's memory in bytes
seg_inf()
- : data(nullptr)
+ : data(nullptr)
, _size(0)
, freepos(0)
{
@@ -46,23 +46,23 @@ protected:
const char* Name; // for debug memory usage
protected:
void check_capacity(size_t len) {
- if (Y_UNLIKELY(!last_free || len > last_free)) {
+ if (Y_UNLIKELY(!last_free || len > last_free)) {
if (curseg != segs.end() && curseg->freepos > 0)
++curseg;
last_free = (len > segment_size ? len : segment_size);
if (curseg == segs.end() || curseg->_size < last_free) {
segs.push_back(seg_inf(seg_allocator.allocate(last_free), last_free));
- if (Y_UNLIKELY(Name))
+ if (Y_UNLIKELY(Name))
printf("Pool \"%s\" was increased by %" PRISZT " bytes to %" PRISZT " Mb.\n", Name, last_free * sizeof(T), capacity() / 0x100000);
curseg = segs.end() - 1;
}
- Y_ASSERT(curseg->freepos == 0);
- Y_ASSERT(curseg->_size >= last_free);
+ Y_ASSERT(curseg->freepos == 0);
+ Y_ASSERT(curseg->_size >= last_free);
}
}
public:
- explicit segmented_pool(size_t segsz, const char* name = nullptr)
+ explicit segmented_pool(size_t segsz, const char* name = nullptr)
: segment_size(segsz)
, last_free(0)
, last_ins_size(0)
@@ -131,18 +131,18 @@ public:
last_ins_size = 0;
}
void undo_last_append() {
- Y_ASSERT(curseg != segs.end()); // do not use before append()
+ Y_ASSERT(curseg != segs.end()); // do not use before append()
if (last_ins_size) {
- Y_ASSERT(last_ins_size <= curseg->freepos);
+ Y_ASSERT(last_ins_size <= curseg->freepos);
curseg->freepos -= last_ins_size;
last_free += last_ins_size / sizeof(T);
last_ins_size = 0;
}
}
void alloc_first_seg() {
- Y_ASSERT(capacity() == 0);
+ Y_ASSERT(capacity() == 0);
check_capacity(segment_size);
- Y_ASSERT(capacity() == segment_size * sizeof(T));
+ Y_ASSERT(capacity() == segment_size * sizeof(T));
}
};
@@ -151,27 +151,27 @@ private:
using _Base = segmented_pool<char>;
public:
- segmented_string_pool()
- : segmented_string_pool(1024 * 1024)
- {
- }
-
- explicit segmented_string_pool(size_t segsz)
+ segmented_string_pool()
+ : segmented_string_pool(1024 * 1024)
+ {
+ }
+
+ explicit segmented_string_pool(size_t segsz)
: _Base(segsz)
{
}
char* append(const char* src) {
- Y_ASSERT(src);
+ Y_ASSERT(src);
return _Base::append(src, strlen(src) + 1);
}
char* append(const char* src, size_t len) {
- char* rv = _Base::append(nullptr, len + 1);
+ char* rv = _Base::append(nullptr, len + 1);
if (src)
memcpy(rv, src, len);
rv[len] = 0;
return rv;
}
- char* Append(const TStringBuf s) {
+ char* Append(const TStringBuf s) {
return append(s.data(), s.size());
}
void align_4() {
@@ -180,7 +180,7 @@ public:
curseg->freepos = t;
}
char* Allocate(size_t len) {
- return append(nullptr, len);
+ return append(nullptr, len);
}
};
diff --git a/util/memory/segpool_alloc.h b/util/memory/segpool_alloc.h
index ce23fd6392..1a83b7a543 100644
--- a/util/memory/segpool_alloc.h
+++ b/util/memory/segpool_alloc.h
@@ -45,40 +45,40 @@ struct segpool_alloc {
segpool_alloc()
: pool(nullptr)
{
- Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
+ Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
}
segpool_alloc(pool_type* p)
: pool(p)
{
- Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
+ Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
}
segpool_alloc(const segpool_alloc& a)
: pool(a.pool)
{
- Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
+ Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
}
template <class _Tp1>
segpool_alloc(const segpool_alloc<_Tp1>& a)
: pool(a.pool)
{
- Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
+ Y_IF_DEBUG(pool_count = malloc_count = pool_free_count = malloc_free_count = 0);
}
_Tp* allocate(size_t __n) {
if (!pool) {
_Tp* data = (_Tp*)malloc(__n * sizeof(_Tp));
- Y_IF_DEBUG(if (data) malloc_count++);
+ Y_IF_DEBUG(if (data) malloc_count++);
return data;
}
_Tp* data = (_Tp*)pool->append(nullptr, __n * sizeof(_Tp));
- Y_IF_DEBUG(pool_count++);
+ Y_IF_DEBUG(pool_count++);
return data;
}
void deallocate(pointer __p, size_t /*__n*/) {
if (!pool) {
- Y_IF_DEBUG(malloc_free_count++);
+ Y_IF_DEBUG(malloc_free_count++);
free(__p);
} else {
- Y_IF_DEBUG(pool_free_count++);
+ Y_IF_DEBUG(pool_free_count++);
;
}
}
diff --git a/util/memory/smallobj.h b/util/memory/smallobj.h
index 6fbfa83665..63de666bae 100644
--- a/util/memory/smallobj.h
+++ b/util/memory/smallobj.h
@@ -55,7 +55,7 @@ public:
}
inline void* Allocate() {
- if (Y_UNLIKELY(Free_.Empty())) {
+ if (Y_UNLIKELY(Free_.Empty())) {
return Pool_.Allocate(AllocSize_, AlignSize_);
}
diff --git a/util/memory/smallobj_ut.cpp b/util/memory/smallobj_ut.cpp
index 8730e97e22..86003d1d53 100644
--- a/util/memory/smallobj_ut.cpp
+++ b/util/memory/smallobj_ut.cpp
@@ -17,7 +17,7 @@ class TSmallObjAllocTest: public TTestBase {
}
};
- struct TClass64: public TObjectFromPool<TClass64> {
+ struct TClass64: public TObjectFromPool<TClass64> {
alignas(64) ui64 Data = 0;
};
@@ -30,10 +30,10 @@ class TSmallObjAllocTest: public TTestBase {
private:
void TestAlign() {
TClass64::TPool pool(TDefaultAllocator::Instance());
- TClass64* f1 = new (&pool) TClass64;
- TClass64* f2 = new (&pool) TClass64;
- TClass64* f3 = new (&pool) TClass64;
- TClass64* f4 = new (&pool) TClass64;
+ TClass64* f1 = new (&pool) TClass64;
+ TClass64* f2 = new (&pool) TClass64;
+ TClass64* f3 = new (&pool) TClass64;
+ TClass64* f4 = new (&pool) TClass64;
UNIT_ASSERT_VALUES_EQUAL(64u, alignof(TClass64));
UNIT_ASSERT_VALUES_EQUAL((size_t)0, (size_t)(f1) & (alignof(TClass64) - 1));
UNIT_ASSERT_VALUES_EQUAL((size_t)0, (size_t)(f2) & (alignof(TClass64) - 1));
@@ -70,8 +70,8 @@ private:
alloced.insert(c);
}
- for (auto it : alloced) {
- delete it;
+ for (auto it : alloced) {
+ delete it;
}
for (size_t i = 0; i < 10000; ++i) {
diff --git a/util/memory/tempbuf.cpp b/util/memory/tempbuf.cpp
index 6e87d94c49..09a2d0f140 100644
--- a/util/memory/tempbuf.cpp
+++ b/util/memory/tempbuf.cpp
@@ -54,12 +54,12 @@ public:
}
void SetPos(size_t off) {
- Y_ASSERT(off <= Size());
+ Y_ASSERT(off <= Size());
Offset_ = off;
}
inline void Proceed(size_t off) {
- Y_ASSERT(off <= Left());
+ Y_ASSERT(off <= Left());
Offset_ += off;
}
diff --git a/util/memory/tempbuf.h b/util/memory/tempbuf.h
index 2cc3ebe867..334670eb1e 100644
--- a/util/memory/tempbuf.h
+++ b/util/memory/tempbuf.h
@@ -59,10 +59,10 @@ private:
static const T* TypedPointer(const char* pointer) noexcept {
return reinterpret_cast<const T*>(pointer);
}
- static constexpr size_t RawSize(const size_t size) noexcept {
+ static constexpr size_t RawSize(const size_t size) noexcept {
return size * sizeof(T);
}
- static constexpr size_t TypedSize(const size_t size) noexcept {
+ static constexpr size_t TypedSize(const size_t size) noexcept {
return size / sizeof(T);
}
diff --git a/util/network/address.cpp b/util/network/address.cpp
index 906608d30f..a81a9e6994 100644
--- a/util/network/address.cpp
+++ b/util/network/address.cpp
@@ -10,7 +10,7 @@
using namespace NAddr;
template <bool printPort>
-static inline void PrintAddr(IOutputStream& out, const IRemoteAddr& addr) {
+static inline void PrintAddr(IOutputStream& out, const IRemoteAddr& addr) {
const sockaddr* a = addr.Addr();
char buf[INET6_ADDRSTRLEN + 10];
@@ -90,7 +90,7 @@ static inline void PrintAddr(IOutputStream& out, const IRemoteAddr& addr) {
}
template <>
-void Out<IRemoteAddr>(IOutputStream& out, const IRemoteAddr& addr) {
+void Out<IRemoteAddr>(IOutputStream& out, const IRemoteAddr& addr) {
PrintAddr<true>(out, addr);
}
@@ -114,7 +114,7 @@ void Out<NAddr::TOpaqueAddr>(IOutputStream& out, const NAddr::TOpaqueAddr& addr)
PrintAddr<true>(out, addr);
}
-void NAddr::PrintHost(IOutputStream& out, const IRemoteAddr& addr) {
+void NAddr::PrintHost(IOutputStream& out, const IRemoteAddr& addr) {
PrintAddr<false>(out, addr);
}
diff --git a/util/network/address.h b/util/network/address.h
index d9f310ae9d..448fcac0c9 100644
--- a/util/network/address.h
+++ b/util/network/address.h
@@ -20,7 +20,7 @@ namespace NAddr {
IRemoteAddrPtr GetSockAddr(SOCKET s);
IRemoteAddrPtr GetPeerAddr(SOCKET s);
- void PrintHost(IOutputStream& out, const IRemoteAddr& addr);
+ void PrintHost(IOutputStream& out, const IRemoteAddr& addr);
TString PrintHost(const IRemoteAddr& addr);
TString PrintHostAndPort(const IRemoteAddr& addr);
diff --git a/util/network/address_ut.cpp b/util/network/address_ut.cpp
index 98f75d95f4..28f45172ff 100644
--- a/util/network/address_ut.cpp
+++ b/util/network/address_ut.cpp
@@ -4,8 +4,8 @@
using namespace NAddr;
-Y_UNIT_TEST_SUITE(IRemoteAddr_ToString) {
- Y_UNIT_TEST(Raw) {
+Y_UNIT_TEST_SUITE(IRemoteAddr_ToString) {
+ Y_UNIT_TEST(Raw) {
THolder<TOpaqueAddr> opaque(new TOpaqueAddr);
IRemoteAddr* addr = opaque.Get();
@@ -16,11 +16,11 @@ Y_UNIT_TEST_SUITE(IRemoteAddr_ToString) {
TString t = ToString(*addr);
- UNIT_ASSERT_C(t.StartsWith("(raw 0 0"), t);
- UNIT_ASSERT_C(t.EndsWith(')'), t);
+ UNIT_ASSERT_C(t.StartsWith("(raw 0 0"), t);
+ UNIT_ASSERT_C(t.EndsWith(')'), t);
}
- Y_UNIT_TEST(Ipv6) {
+ Y_UNIT_TEST(Ipv6) {
TNetworkAddress address("::1", 22);
TNetworkAddress::TIterator it = address.Begin();
UNIT_ASSERT(it != address.End());
diff --git a/util/network/endpoint_ut.cpp b/util/network/endpoint_ut.cpp
index f812065805..d5e40dd6e1 100644
--- a/util/network/endpoint_ut.cpp
+++ b/util/network/endpoint_ut.cpp
@@ -5,8 +5,8 @@
#include <util/generic/hash_set.h>
#include <util/generic/strbuf.h>
-Y_UNIT_TEST_SUITE(TEndpointTest) {
- Y_UNIT_TEST(TestSimple) {
+Y_UNIT_TEST_SUITE(TEndpointTest) {
+ Y_UNIT_TEST(TestSimple) {
TVector<TNetworkAddress> addrs;
TEndpoint ep0;
@@ -86,7 +86,7 @@ Y_UNIT_TEST_SUITE(TEndpointTest) {
UNIT_ASSERT_VALUES_EQUAL(5u, he.size());
}
- Y_UNIT_TEST(TestEqual) {
+ Y_UNIT_TEST(TestEqual) {
const TString ip1 = "2a02:6b8:0:1410::5f6c:f3c2";
const TString ip2 = "2a02:6b8:0:1410::5f6c:f3c3";
diff --git a/util/network/hostip.cpp b/util/network/hostip.cpp
index 62085e7c5b..cb8d43bf90 100644
--- a/util/network/hostip.cpp
+++ b/util/network/hostip.cpp
@@ -28,8 +28,8 @@ int NResolver::GetHostIP(const char* hostname, ui32* ip, size_t* slots) {
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
- struct addrinfo* gai_res = nullptr;
- int gai_ret = getaddrinfo(hostname, nullptr, &hints, &gai_res);
+ struct addrinfo* gai_res = nullptr;
+ int gai_ret = getaddrinfo(hostname, nullptr, &hints, &gai_res);
if (gai_ret == 0 && gai_res->ai_addr) {
struct addrinfo* cur = gai_res;
for (i = 0; i < *slots && cur; i++, cur = cur->ai_next, ipsFound++) {
diff --git a/util/network/init.cpp b/util/network/init.cpp
index 26561c173a..366e65682c 100644
--- a/util/network/init.cpp
+++ b/util/network/init.cpp
@@ -8,26 +8,26 @@
#include <cstdio>
#include <cstdlib>
-namespace {
- class TNetworkInit {
- public:
- inline TNetworkInit() {
+namespace {
+ class TNetworkInit {
+ public:
+ inline TNetworkInit() {
#ifndef ROBOT_SIGPIPE
- signal(SIGPIPE, SIG_IGN);
+ signal(SIGPIPE, SIG_IGN);
#endif
#if defined(_win_)
#pragma comment(lib, "ws2_32.lib")
- WSADATA wsaData;
- int result = WSAStartup(MAKEWORD(2, 2), &wsaData);
- Y_ASSERT(!result);
- if (result) {
- exit(-1);
- }
-#endif
+ WSADATA wsaData;
+ int result = WSAStartup(MAKEWORD(2, 2), &wsaData);
+ Y_ASSERT(!result);
+ if (result) {
+ exit(-1);
+ }
+#endif
}
- };
-}
+ };
+}
void InitNetworkSubSystem() {
(void)Singleton<TNetworkInit>();
diff --git a/util/network/init.h b/util/network/init.h
index 33a3e7f435..08a79c0fca 100644
--- a/util/network/init.h
+++ b/util/network/init.h
@@ -49,7 +49,7 @@ struct sockaddr_un {
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif
-#endif // _win_ or _darwin_
+#endif // _win_ or _darwin_
void InitNetworkSubSystem();
diff --git a/util/network/interface.cpp b/util/network/interface.cpp
index 1ad5f21191..256776c6d3 100644
--- a/util/network/interface.cpp
+++ b/util/network/interface.cpp
@@ -11,7 +11,7 @@
namespace NAddr {
static bool IsInetAddress(sockaddr* addr) {
- return (addr != nullptr) && ((addr->sa_family == AF_INET) || (addr->sa_family == AF_INET6));
+ return (addr != nullptr) && ((addr->sa_family == AF_INET) || (addr->sa_family == AF_INET6));
}
TNetworkInterfaceList GetNetworkInterfaces() {
@@ -23,7 +23,7 @@ namespace NAddr {
PIP_ADAPTER_ADDRESSES adapterBuf = (PIP_ADAPTER_ADDRESSES)&buf[0];
ULONG bufSize = buf.ysize();
- if (GetAdaptersAddresses(AF_UNSPEC, 0, nullptr, adapterBuf, &bufSize) == ERROR_SUCCESS) {
+ if (GetAdaptersAddresses(AF_UNSPEC, 0, nullptr, adapterBuf, &bufSize) == ERROR_SUCCESS) {
for (PIP_ADAPTER_ADDRESSES ptr = adapterBuf; ptr != 0; ptr = ptr->Next) {
// The check below makes code working on Vista+
if ((ptr->Flags & (IP_ADAPTER_IPV4_ENABLED | IP_ADAPTER_IPV6_ENABLED)) == 0) {
@@ -59,7 +59,7 @@ namespace NAddr {
#else
ifaddrs* ifap;
if (getifaddrs(&ifap) != -1) {
- for (ifaddrs* ifa = ifap; ifa != nullptr; ifa = ifa->ifa_next) {
+ for (ifaddrs* ifa = ifap; ifa != nullptr; ifa = ifa->ifa_next) {
if (IsInetAddress(ifa->ifa_addr)) {
TNetworkInterface interface;
interface.Name = ifa->ifa_name;
diff --git a/util/network/iovec.h b/util/network/iovec.h
index cabc453492..ac15a41f54 100644
--- a/util/network/iovec.h
+++ b/util/network/iovec.h
@@ -5,7 +5,7 @@
#include <util/system/yassert.h>
class TContIOVector {
- using TPart = IOutputStream::TPart;
+ using TPart = IOutputStream::TPart;
public:
inline TContIOVector(TPart* parts, size_t count)
diff --git a/util/network/ip_ut.cpp b/util/network/ip_ut.cpp
index 71fbba21f3..6716c6a699 100644
--- a/util/network/ip_ut.cpp
+++ b/util/network/ip_ut.cpp
@@ -29,7 +29,7 @@ void TSysIpTest::TestIpFromString() {
const char* ipStr[] = {"192.168.0.1", "87.255.18.167", "255.255.0.31", "188.225.124.255"};
ui8 ipArr[][4] = {{192, 168, 0, 1}, {87, 255, 18, 167}, {255, 255, 0, 31}, {188, 225, 124, 255}};
- for (size_t i = 0; i < Y_ARRAY_SIZE(ipStr); ++i) {
+ for (size_t i = 0; i < Y_ARRAY_SIZE(ipStr); ++i) {
const ui32 ip = IpFromString(ipStr[i]);
UNIT_ASSERT(memcmp(&ip, ipArr[i], sizeof(ui32)) == 0);
@@ -57,7 +57,7 @@ void TSysIpTest::TestIpToString() {
const char* ipStr[] = {"192.168.0.1", "87.255.18.167", "255.255.0.31", "188.225.124.255"};
- for (size_t i = 0; i < Y_ARRAY_SIZE(ipStr); ++i) {
+ for (size_t i = 0; i < Y_ARRAY_SIZE(ipStr); ++i) {
UNIT_ASSERT(IpToString(*reinterpret_cast<TIpHost*>(&(ipArr[i]))) == ipStr[i]);
}
}
diff --git a/util/network/nonblock.cpp b/util/network/nonblock.cpp
index dcc7360e62..e515c27cc5 100644
--- a/util/network/nonblock.cpp
+++ b/util/network/nonblock.cpp
@@ -17,7 +17,7 @@
namespace {
struct TFeatureCheck {
inline TFeatureCheck()
- : Accept4(nullptr)
+ : Accept4(nullptr)
, HaveSockNonBlock(false)
{
#if defined(_unix_) && defined(SOCK_NONBLOCK)
@@ -32,10 +32,10 @@ namespace {
#endif
if (Accept4) {
- Accept4(-1, nullptr, nullptr, SOCK_NONBLOCK);
+ Accept4(-1, nullptr, nullptr, SOCK_NONBLOCK);
if (errno == ENOSYS) {
- Accept4 = nullptr;
+ Accept4 = nullptr;
}
}
}
diff --git a/util/network/pair.cpp b/util/network/pair.cpp
index 384fd03620..9751ef5c96 100644
--- a/util/network/pair.cpp
+++ b/util/network/pair.cpp
@@ -50,13 +50,13 @@ int SocketPair(SOCKET socks[2], bool overlapped, bool cloexec) {
if (listen(listener, 1) == SOCKET_ERROR)
break;
- if ((socks[0] = WSASocket(AF_INET, SOCK_STREAM, 0, nullptr, 0, flags)) == INVALID_SOCKET)
+ if ((socks[0] = WSASocket(AF_INET, SOCK_STREAM, 0, nullptr, 0, flags)) == INVALID_SOCKET)
break;
if (connect(socks[0], (const struct sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR)
break;
- if ((socks[1] = accept(listener, nullptr, nullptr)) == INVALID_SOCKET)
+ if ((socks[1] = accept(listener, nullptr, nullptr)) == INVALID_SOCKET)
break;
closesocket(listener);
diff --git a/util/network/poller.h b/util/network/poller.h
index 8ae414d4f3..8dccd73140 100644
--- a/util/network/poller.h
+++ b/util/network/poller.h
@@ -41,7 +41,7 @@ public:
return ret;
}
- return nullptr;
+ return nullptr;
}
inline void* WaitT(const TDuration& timeOut) {
diff --git a/util/network/poller_ut.cpp b/util/network/poller_ut.cpp
index 0e19bff4c1..6df0dda8ec 100644
--- a/util/network/poller_ut.cpp
+++ b/util/network/poller_ut.cpp
@@ -1,12 +1,12 @@
#include <library/cpp/testing/unittest/registar.h>
#include <util/system/error.h>
-#include "pair.h"
+#include "pair.h"
#include "poller.h"
#include "pollerimpl.h"
-Y_UNIT_TEST_SUITE(TSocketPollerTest) {
- Y_UNIT_TEST(TestSimple) {
+Y_UNIT_TEST_SUITE(TSocketPollerTest) {
+ Y_UNIT_TEST(TestSimple) {
SOCKET sockets[2];
UNIT_ASSERT(SocketPair(sockets) == 0);
@@ -16,8 +16,8 @@ Y_UNIT_TEST_SUITE(TSocketPollerTest) {
TSocketPoller poller;
poller.WaitRead(sockets[1], (void*)17);
- UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
- UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
+ UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
+ UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
for (ui32 i = 0; i < 3; ++i) {
char buf[] = {18};
@@ -28,12 +28,12 @@ Y_UNIT_TEST_SUITE(TSocketPollerTest) {
UNIT_ASSERT_VALUES_EQUAL(1, recv(sockets[1], buf, 1, 0));
UNIT_ASSERT_VALUES_EQUAL(18, buf[0]);
- UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
- UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
+ UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
+ UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
}
}
- Y_UNIT_TEST(TestSimpleOneShot) {
+ Y_UNIT_TEST(TestSimpleOneShot) {
SOCKET sockets[2];
UNIT_ASSERT(SocketPair(sockets) == 0);
@@ -42,8 +42,8 @@ Y_UNIT_TEST_SUITE(TSocketPollerTest) {
TSocketPoller poller;
- UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
- UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
+ UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
+ UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
for (ui32 i = 0; i < 3; ++i) {
poller.WaitReadOneShot(sockets[1], (void*)17);
@@ -59,23 +59,23 @@ Y_UNIT_TEST_SUITE(TSocketPollerTest) {
UNIT_ASSERT_VALUES_EQUAL(1, recv(sockets[1], buf, 1, 0));
UNIT_ASSERT_VALUES_EQUAL(char(i + 20), buf[0]);
- UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
- UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
+ UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
+ UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
buf[0] = i + 21;
UNIT_ASSERT_VALUES_EQUAL(1, send(sockets[0], buf, 1, 0));
// this fails if socket is not oneshot
- UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
- UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
+ UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
+ UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero()));
UNIT_ASSERT_VALUES_EQUAL(1, recv(sockets[1], buf, 1, 0));
UNIT_ASSERT_VALUES_EQUAL(char(i + 21), buf[0]);
}
}
- Y_UNIT_TEST(TestItIsSafeToUnregisterUnregisteredDescriptor) {
+ Y_UNIT_TEST(TestItIsSafeToUnregisterUnregisteredDescriptor) {
SOCKET sockets[2];
UNIT_ASSERT(SocketPair(sockets) == 0);
@@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(TSocketPollerTest) {
poller.Unwait(s1);
}
- Y_UNIT_TEST(TestItIsSafeToReregisterDescriptor) {
+ Y_UNIT_TEST(TestItIsSafeToReregisterDescriptor) {
SOCKET sockets[2];
UNIT_ASSERT(SocketPair(sockets) == 0);
@@ -96,9 +96,9 @@ Y_UNIT_TEST_SUITE(TSocketPollerTest) {
TSocketPoller poller;
- poller.WaitRead(s1, nullptr);
- poller.WaitRead(s1, nullptr);
- poller.WaitWrite(s1, nullptr);
+ poller.WaitRead(s1, nullptr);
+ poller.WaitRead(s1, nullptr);
+ poller.WaitWrite(s1, nullptr);
}
Y_UNIT_TEST(TestSimpleEdgeTriggered) {
diff --git a/util/network/pollerimpl.h b/util/network/pollerimpl.h
index 103df45afe..e8c7e40fba 100644
--- a/util/network/pollerimpl.h
+++ b/util/network/pollerimpl.h
@@ -126,7 +126,7 @@ public:
EV_SET(e + 0, fd, EVFILT_READ, flags | ((what & CONT_POLL_READ) ? EV_ENABLE : EV_DISABLE), 0, 0, data);
EV_SET(e + 1, fd, EVFILT_WRITE, flags | ((what & CONT_POLL_WRITE) ? EV_ENABLE : EV_DISABLE), 0, 0, data);
- if (Kevent(Fd_, e, 2, nullptr, 0, nullptr) == -1) {
+ if (Kevent(Fd_, e, 2, nullptr, 0, nullptr) == -1) {
ythrow TSystemError() << "kevent add failed";
}
}
@@ -139,7 +139,7 @@ public:
EV_SET(e + 0, fd, EVFILT_READ, EV_DELETE, 0, 0, 0);
EV_SET(e + 1, fd, EVFILT_WRITE, EV_DELETE, 0, 0, 0);
- Y_VERIFY(!(Kevent(Fd_, e, 2, nullptr, 0, nullptr) == -1 && errno != ENOENT), "kevent remove failed: %s", LastSystemErrorText());
+ Y_VERIFY(!(Kevent(Fd_, e, 2, nullptr, 0, nullptr) == -1 && errno != ENOENT), "kevent remove failed: %s", LastSystemErrorText());
}
inline size_t Wait(TEvent* events, size_t len, int timeout) noexcept {
@@ -148,9 +148,9 @@ public:
ts.tv_sec = timeout / 1000000;
ts.tv_nsec = (timeout % 1000000) * 1000;
- const int ret = Kevent(Fd_, nullptr, 0, events, len, &ts);
+ const int ret = Kevent(Fd_, nullptr, 0, events, len, &ts);
- Y_VERIFY(ret >= 0, "kevent failed: %s", LastSystemErrorText());
+ Y_VERIFY(ret >= 0, "kevent failed: %s", LastSystemErrorText());
return (size_t)ret;
}
@@ -269,7 +269,7 @@ public:
inline size_t Wait(TEvent* events, size_t len, int timeout) noexcept {
const int ret = ContEpollWait(Fd_, events, len, MicroToMilli(timeout));
- Y_VERIFY(ret >= 0, "epoll wait error: %s", LastSystemErrorText());
+ Y_VERIFY(ret >= 0, "epoll wait error: %s", LastSystemErrorText());
return (size_t)ret;
}
@@ -331,7 +331,7 @@ struct TSelectPollerNoTemplate {
int Filter_;
inline THandle()
- : Data_(nullptr)
+ : Data_(nullptr)
, Filter_(0)
{
}
@@ -367,9 +367,9 @@ struct TSelectPollerNoTemplate {
inline SOCKET Build(fd_set* r, fd_set* w, fd_set* e) const noexcept {
SOCKET ret = 0;
- for (const auto& it : *this) {
- const SOCKET fd = it.first;
- const THandle& handle = it.second;
+ for (const auto& it : *this) {
+ const SOCKET fd = it.first;
+ const THandle& handle = it.second;
FD_SET(fd, e);
@@ -411,8 +411,8 @@ class TSelectPoller: public TSelectPollerNoTemplate {
public:
inline TSelectPoller()
- : Begin_(nullptr)
- , End_(nullptr)
+ : Begin_(nullptr)
+ , End_(nullptr)
{
SocketPair(Signal_);
SetNonBlock(WaitSock());
@@ -519,7 +519,7 @@ public:
TryWait();
}
- Y_VERIFY(ret >= 0 && (size_t)ret <= len, "select error: %s", LastSystemErrorText());
+ Y_VERIFY(ret >= 0 && (size_t)ret <= len, "select error: %s", LastSystemErrorText());
TEvent* eventsStart = events;
@@ -598,7 +598,7 @@ private:
char ch[32];
while (recv(WaitSock(), ch, sizeof(ch), 0) > 0) {
- Y_ASSERT(ch[0] == 13);
+ Y_ASSERT(ch[0] == 13);
}
}
diff --git a/util/network/sock.h b/util/network/sock.h
index ea558f22e1..b10be2f715 100644
--- a/util/network/sock.h
+++ b/util/network/sock.h
@@ -3,7 +3,7 @@
#include <util/folder/path.h>
#include <util/system/defaults.h>
#include <util/string/cast.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/system/sysstat.h>
#if defined(_win_) || defined(_cygwin_)
@@ -17,11 +17,11 @@
#include "ip.h"
#include "socket.h"
-constexpr ui16 DEF_LOCAL_SOCK_MODE = 00644;
+constexpr ui16 DEF_LOCAL_SOCK_MODE = 00644;
// Base abstract class for socket address
-struct ISockAddr {
- virtual ~ISockAddr() = default;
+struct ISockAddr {
+ virtual ~ISockAddr() = default;
// Max size of the address that we can store (arg of recvfrom)
virtual socklen_t Size() const = 0;
// Real length of the address (arg of sendto)
@@ -47,7 +47,7 @@ protected:
#if defined(_win_) || defined(_cygwin_)
#define YAF_LOCAL AF_INET
-struct TSockAddrLocal: public ISockAddr {
+struct TSockAddrLocal: public ISockAddr {
TSockAddrLocal() {
Clear();
}
@@ -111,7 +111,7 @@ struct TSockAddrLocal: public ISockAddr {
}
int Bind(SOCKET s, ui16 mode) const {
- Y_UNUSED(mode);
+ Y_UNUSED(mode);
int ret = 0;
// 1. open file
TFileHandle f(Path, CreateAlways | WrOnly);
@@ -137,13 +137,13 @@ struct TSockAddrLocal: public ISockAddr {
return 0;
}
- static constexpr size_t PathSize = 128;
+ static constexpr size_t PathSize = 128;
mutable struct sockaddr_in in;
char Path[PathSize];
};
#else
#define YAF_LOCAL AF_LOCAL
-struct TSockAddrLocal: public sockaddr_un, public ISockAddr {
+struct TSockAddrLocal: public sockaddr_un, public ISockAddr {
TSockAddrLocal() {
Clear();
}
@@ -201,7 +201,7 @@ struct TSockAddrLocal: public sockaddr_un, public ISockAddr {
};
#endif // _win_
-struct TSockAddrInet: public sockaddr_in, public ISockAddr {
+struct TSockAddrInet: public sockaddr_in, public ISockAddr {
TSockAddrInet() {
Clear();
}
@@ -246,7 +246,7 @@ struct TSockAddrInet: public sockaddr_in, public ISockAddr {
}
int Bind(SOCKET s, ui16 mode) const override {
- Y_UNUSED(mode);
+ Y_UNUSED(mode);
int ret = bind(s, SockAddr(), Len());
if (ret < 0)
return -errno;
@@ -271,7 +271,7 @@ struct TSockAddrInet: public sockaddr_in, public ISockAddr {
}
};
-struct TSockAddrInet6: public sockaddr_in6, public ISockAddr {
+struct TSockAddrInet6: public sockaddr_in6, public ISockAddr {
TSockAddrInet6() {
Clear();
}
@@ -312,7 +312,7 @@ struct TSockAddrInet6: public sockaddr_in6, public ISockAddr {
}
int Bind(SOCKET s, ui16 mode) const override {
- Y_UNUSED(mode);
+ Y_UNUSED(mode);
int ret = bind(s, SockAddr(), Len());
if (ret < 0) {
return -errno;
@@ -354,7 +354,7 @@ protected:
}
public:
- int Bind(const ISockAddr* addr, ui16 mode = DEF_LOCAL_SOCK_MODE) {
+ int Bind(const ISockAddr* addr, ui16 mode = DEF_LOCAL_SOCK_MODE) {
return addr->Bind((SOCKET) * this, mode);
}
@@ -378,7 +378,7 @@ protected:
}
public:
- ssize_t SendTo(const void* msg, size_t len, const ISockAddr* toAddr) {
+ ssize_t SendTo(const void* msg, size_t len, const ISockAddr* toAddr) {
ssize_t ret = toAddr->ResolveAddr();
if (ret < 0) {
return -LastSystemError();
@@ -392,7 +392,7 @@ public:
return ret;
}
- ssize_t RecvFrom(void* buf, size_t len, ISockAddr* fromAddr) {
+ ssize_t RecvFrom(void* buf, size_t len, ISockAddr* fromAddr) {
socklen_t fromSize = fromAddr->Size();
const ssize_t ret = recvfrom((SOCKET) * this, (char*)buf, (int)len, 0, fromAddr->SockAddr(), &fromSize);
if (ret < 0) {
@@ -432,7 +432,7 @@ public:
return ret;
}
- int Connect(const ISockAddr* addr) {
+ int Connect(const ISockAddr* addr) {
int ret = addr->ResolveAddr();
if (ret < 0)
return -errno;
@@ -548,7 +548,7 @@ public:
}
};
-class TStreamSocketInput: public IInputStream {
+class TStreamSocketInput: public IInputStream {
public:
TStreamSocketInput(TStreamSocket* socket)
: Socket(socket)
@@ -562,7 +562,7 @@ protected:
TStreamSocket* Socket;
size_t DoRead(void* buf, size_t len) override {
- Y_VERIFY(Socket, "TStreamSocketInput: socket isn't set");
+ Y_VERIFY(Socket, "TStreamSocketInput: socket isn't set");
const ssize_t ret = Socket->Recv(buf, len);
if (ret >= 0) {
@@ -573,7 +573,7 @@ protected:
}
};
-class TStreamSocketOutput: public IOutputStream {
+class TStreamSocketOutput: public IOutputStream {
public:
TStreamSocketOutput(TStreamSocket* socket)
: Socket(socket)
@@ -590,7 +590,7 @@ protected:
TStreamSocket* Socket;
void DoWrite(const void* buf, size_t len) override {
- Y_VERIFY(Socket, "TStreamSocketOutput: socket isn't set");
+ Y_VERIFY(Socket, "TStreamSocketOutput: socket isn't set");
const char* ptr = (const char*)buf;
while (len) {
@@ -600,7 +600,7 @@ protected:
ythrow TSystemError(-(int)ret) << "can not write to socket output stream";
}
- Y_ASSERT((size_t)ret <= len);
+ Y_ASSERT((size_t)ret <= len);
len -= (size_t)ret;
ptr += (size_t)ret;
}
diff --git a/util/network/sock_ut.cpp b/util/network/sock_ut.cpp
index 3ba7eafc75..fd8c783747 100644
--- a/util/network/sock_ut.cpp
+++ b/util/network/sock_ut.cpp
@@ -5,8 +5,8 @@
#include <util/system/fs.h>
-Y_UNIT_TEST_SUITE(TSocketTest) {
- Y_UNIT_TEST(InetDgramTest) {
+Y_UNIT_TEST_SUITE(TSocketTest) {
+ Y_UNIT_TEST(InetDgramTest) {
char buf[256];
TSockAddrInetDgram servAddr(IpFromString("127.0.0.1"), 0);
TSockAddrInetDgram cliAddr(IpFromString("127.0.0.1"), 0);
@@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(TSocketTest) {
UNIT_ASSERT(strcmp(repStr, buf) == 0);
}
- Y_UNIT_TEST(LocalDgramTest) {
+ Y_UNIT_TEST(LocalDgramTest) {
const char* localServerSockName = "./serv_sock";
const char* localClientSockName = "./cli_sock";
RunLocalDgramTest(localServerSockName, localClientSockName);
@@ -111,11 +111,11 @@ Y_UNIT_TEST_SUITE(TSocketTest) {
UNIT_ASSERT(strcmp(repStr, buf) == 0);
}
- Y_UNIT_TEST(InetStreamTest) {
+ Y_UNIT_TEST(InetStreamTest) {
RunInetStreamTest<TSockAddrInetStream, TInetStreamSocket>("127.0.0.1");
}
- Y_UNIT_TEST(Inet6StreamTest) {
+ Y_UNIT_TEST(Inet6StreamTest) {
RunInetStreamTest<TSockAddrInet6Stream, TInet6StreamSocket>("::1");
}
@@ -159,7 +159,7 @@ Y_UNIT_TEST_SUITE(TSocketTest) {
UNIT_ASSERT(strcmp(repStr, buf) == 0);
}
- Y_UNIT_TEST(LocalStreamTest) {
+ Y_UNIT_TEST(LocalStreamTest) {
const char* localServerSockName = "./serv_sock2";
RunLocalStreamTest(localServerSockName);
NFs::Remove(localServerSockName);
diff --git a/util/network/socket.cpp b/util/network/socket.cpp
index 0d44f7bac7..4f6e804346 100644
--- a/util/network/socket.cpp
+++ b/util/network/socket.cpp
@@ -36,7 +36,7 @@
#include <util/generic/ylimits.h>
#include <util/string/cast.h>
-#include <util/stream/mem.h>
+#include <util/stream/mem.h>
#include <util/system/datetime.h>
#include <util/system/error.h>
#include <util/memory/tempbuf.h>
@@ -54,7 +54,7 @@ int inet_aton(const char* cp, struct in_addr* inp) {
sockaddr_in addr;
addr.sin_family = AF_INET;
int psz = sizeof(addr);
- if (0 == WSAStringToAddress((char*)cp, AF_INET, nullptr, (LPSOCKADDR)&addr, &psz)) {
+ if (0 == WSAStringToAddress((char*)cp, AF_INET, nullptr, (LPSOCKADDR)&addr, &psz)) {
memcpy(inp, &addr.sin_addr, sizeof(in_addr));
return 1;
}
@@ -180,7 +180,7 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept {
if (fd->events & POLLOUT) {
FD_SET(fd->fd, &writefds);
}
- int error = select(0, &readfds, &writefds, nullptr, &timeout);
+ int error = select(0, &readfds, &writefds, nullptr, &timeout);
if (error > 0) {
if (FD_ISSET(fd->fd, &readfds)) {
fd->revents |= POLLIN;
@@ -315,8 +315,8 @@ void SetReusePort(SOCKET s, bool value) {
#if defined(SO_REUSEPORT)
CheckedSetSockOpt(s, SOL_SOCKET, SO_REUSEPORT, (int)value, "reuse port");
#else
- Y_UNUSED(s);
- Y_UNUSED(value);
+ Y_UNUSED(s);
+ Y_UNUSED(value);
ythrow TSystemError(ENOSYS) << "SO_REUSEPORT is not defined";
#endif
}
@@ -340,8 +340,8 @@ void SetCloseOnExec(SOCKET s, bool value) {
ythrow TSystemError() << "fcntl() failed";
}
#else
- Y_UNUSED(s);
- Y_UNUSED(value);
+ Y_UNUSED(s);
+ Y_UNUSED(value);
#endif
}
@@ -485,8 +485,8 @@ void SetTcpFastOpen(SOCKET s, int qlen) {
#if defined(TCP_FASTOPEN)
TTcpFastOpenFeature::Instance()->SetFastOpen(s, qlen);
#else
- Y_UNUSED(s);
- Y_UNUSED(qlen);
+ Y_UNUSED(s);
+ Y_UNUSED(qlen);
#endif
}
@@ -561,9 +561,9 @@ void TSocketHolder::Close() noexcept {
// because often it means double close
// that is disasterous
#ifdef _win_
- Y_VERIFY(WSAGetLastError() != WSAENOTSOCK, "must not quietly close bad socket descriptor");
+ Y_VERIFY(WSAGetLastError() != WSAENOTSOCK, "must not quietly close bad socket descriptor");
#elif defined(_unix_)
- Y_VERIFY(errno != EBADF, "must not quietly close bad descriptor: fd=%d", int(Fd_));
+ Y_VERIFY(errno != EBADF, "must not quietly close bad descriptor: fd=%d", int(Fd_));
#else
#error unsupported platform
#endif
@@ -611,7 +611,7 @@ private:
};
template <>
-void Out<const struct addrinfo*>(IOutputStream& os, const struct addrinfo* ai) {
+void Out<const struct addrinfo*>(IOutputStream& os, const struct addrinfo* ai) {
if (ai->ai_flags & AI_CANONNAME) {
os << "`" << ai->ai_canonname << "' ";
}
@@ -628,12 +628,12 @@ void Out<const struct addrinfo*>(IOutputStream& os, const struct addrinfo* ai) {
}
template <>
-void Out<struct addrinfo*>(IOutputStream& os, struct addrinfo* ai) {
+void Out<struct addrinfo*>(IOutputStream& os, struct addrinfo* ai) {
Out<const struct addrinfo*>(os, static_cast<const struct addrinfo*>(ai));
}
template <>
-void Out<TNetworkAddress>(IOutputStream& os, const TNetworkAddress& addr) {
+void Out<TNetworkAddress>(IOutputStream& os, const TNetworkAddress& addr) {
os << &*addr.Begin();
}
@@ -919,16 +919,16 @@ TSocketOutput::~TSocketOutput() {
}
void TSocketOutput::DoWrite(const void* buf, size_t len) {
- size_t send = 0;
+ size_t send = 0;
while (len) {
const ssize_t ret = S_.Send(buf, len);
if (ret < 0) {
- ythrow TSystemError(-(int)ret) << "can not write to socket output stream; " << send << " bytes already send";
+ ythrow TSystemError(-(int)ret) << "can not write to socket output stream; " << send << " bytes already send";
}
buf = (const char*)buf + ret;
len -= ret;
- send += ret;
+ send += ret;
}
}
@@ -1080,7 +1080,7 @@ TNetworkAddress::TNetworkAddress(const TString& host, ui16 port)
}
TNetworkAddress::TNetworkAddress(ui16 port)
- : Impl_(new TImpl(nullptr, port, 0))
+ : Impl_(new TImpl(nullptr, port, 0))
{
}
@@ -1091,7 +1091,7 @@ struct addrinfo* TNetworkAddress::Info() const noexcept {
}
TNetworkResolutionError::TNetworkResolutionError(int error) {
- const char* errMsg = nullptr;
+ const char* errMsg = nullptr;
#ifdef _win_
errMsg = LastSystemErrorText(error); // gai_strerror is not thread-safe on Windows
#else
@@ -1163,7 +1163,7 @@ static inline void SetNonBlockSocket(SOCKET fd, int value) {
DWORD written = 0;
if (!inbuf) {
- WSAEventSelect(fd, nullptr, 0);
+ WSAEventSelect(fd, nullptr, 0);
}
if (WSAIoctl(fd, FIONBIO, &inbuf, sizeof(inbuf), &outbuf, sizeof(outbuf), &written, 0, 0) == SOCKET_ERROR) {
@@ -1185,7 +1185,7 @@ static inline bool IsNonBlockSocket(SOCKET fd) {
void SetNonBlock(SOCKET fd, bool value) {
#if defined(_unix_)
#if defined(FIONBIO)
- Y_UNUSED(SetFlag); // shut up clang about unused function
+ Y_UNUSED(SetFlag); // shut up clang about unused function
int nb = value;
if (ioctl(fd, FIONBIO, &nb) < 0) {
diff --git a/util/network/socket.h b/util/network/socket.h
index 9f0e35e1d2..40c8648b40 100644
--- a/util/network/socket.h
+++ b/util/network/socket.h
@@ -5,8 +5,8 @@
#include <util/system/yassert.h>
#include <util/system/defaults.h>
#include <util/system/error.h>
-#include <util/stream/output.h>
-#include <util/stream/input.h>
+#include <util/stream/output.h>
+#include <util/stream/input.h>
#include <util/generic/ptr.h>
#include <util/generic/yexception.h>
#include <util/generic/noncopyable.h>
@@ -223,7 +223,7 @@ public:
}
inline TIterator End() const noexcept {
- return TIterator(nullptr);
+ return TIterator(nullptr);
}
private:
@@ -297,7 +297,7 @@ private:
class TSocket {
public:
- using TPart = IOutputStream::TPart;
+ using TPart = IOutputStream::TPart;
class TOps {
public:
@@ -389,7 +389,7 @@ private:
TSimpleIntrusivePtr<TImpl> Impl_;
};
-class TSocketInput: public IInputStream {
+class TSocketInput: public IInputStream {
public:
TSocketInput(const TSocket& s) noexcept;
~TSocketInput() override;
@@ -408,7 +408,7 @@ private:
TSocket S_;
};
-class TSocketOutput: public IOutputStream {
+class TSocketOutput: public IOutputStream {
public:
TSocketOutput(const TSocket& s) noexcept;
~TSocketOutput() override;
diff --git a/util/network/socket_ut.cpp b/util/network/socket_ut.cpp
index 7156161699..6b20e11f70 100644
--- a/util/network/socket_ut.cpp
+++ b/util/network/socket_ut.cpp
@@ -219,7 +219,7 @@ class TPollTest: public TTestBase {
public:
inline TPollTest() {
- srand(static_cast<unsigned int>(time(nullptr)));
+ srand(static_cast<unsigned int>(time(nullptr)));
}
void TestPollInOut();
@@ -273,7 +273,7 @@ SOCKET TPollTest::StartClientSocket(ui32 ip, ui16 port) {
}
SOCKET TPollTest::AcceptConnection(SOCKET serverSocket) {
- SOCKET connectedSocket = accept(serverSocket, nullptr, nullptr);
+ SOCKET connectedSocket = accept(serverSocket, nullptr, nullptr);
if (connectedSocket == INVALID_SOCKET) {
ythrow yexception() << "Can not accept connection on server socket (" << LastSystemErrorText() << ")";
}
diff --git a/util/random/benchmark/prng/main.cpp b/util/random/benchmark/prng/main.cpp
index 4c3fc3872e..2c6279ff71 100644
--- a/util/random/benchmark/prng/main.cpp
+++ b/util/random/benchmark/prng/main.cpp
@@ -1,12 +1,12 @@
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/random/entropy.h>
-#include <util/random/fast.h>
+
+#include <util/random/entropy.h>
+#include <util/random/fast.h>
#include <util/random/normal.h>
-#include <util/random/mersenne.h>
-#include <util/system/compiler.h>
+#include <util/random/mersenne.h>
+#include <util/system/compiler.h>
#include <util/generic/xrange.h>
-
+
#include <random>
// double part
@@ -15,36 +15,36 @@ Y_CPU_BENCHMARK(Mersenne32_Double, p) {
for (auto i : xrange<size_t>(0, p.Iterations())) {
(void)i;
- Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1());
- }
-}
-
+ Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1());
+ }
+}
+
Y_CPU_BENCHMARK(Mersenne64_Double, p) {
TMersenne<ui64> rng(Seed());
for (auto i : xrange<size_t>(0, p.Iterations())) {
(void)i;
- Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1());
- }
-}
-
+ Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1());
+ }
+}
+
Y_CPU_BENCHMARK(Fast32_Double, p) {
TFastRng<ui32> rng(Seed());
for (auto i : xrange<size_t>(0, p.Iterations())) {
(void)i;
- Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1());
- }
-}
-
+ Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1());
+ }
+}
+
Y_CPU_BENCHMARK(Fast64_Double, p) {
TFastRng<ui64> rng(Seed());
for (auto i : xrange<size_t>(0, p.Iterations())) {
(void)i;
- Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1());
- }
-}
+ Y_DO_NOT_OPTIMIZE_AWAY(rng.GenRandReal1());
+ }
+}
// integer part
Y_CPU_BENCHMARK(mt19937_32, p) {
diff --git a/util/random/benchmark/prng/metrics/main.py b/util/random/benchmark/prng/metrics/main.py
index 7b8174a647..15b371fe75 100644
--- a/util/random/benchmark/prng/metrics/main.py
+++ b/util/random/benchmark/prng/metrics/main.py
@@ -1,5 +1,5 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
metrics.set_benchmark(yc.execute_benchmark('util/random/benchmark/prng/prng', threads=8))
diff --git a/util/random/benchmark/prng/metrics/ya.make b/util/random/benchmark/prng/metrics/ya.make
index 45f0ab0923..1f56aac0bd 100644
--- a/util/random/benchmark/prng/metrics/ya.make
+++ b/util/random/benchmark/prng/metrics/ya.make
@@ -1,21 +1,21 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/random/benchmark/prng)
-
-END()
+
+END()
diff --git a/util/random/benchmark/prng/ya.make b/util/random/benchmark/prng/ya.make
index a475d0c67f..976977014f 100644
--- a/util/random/benchmark/prng/ya.make
+++ b/util/random/benchmark/prng/ya.make
@@ -1,13 +1,13 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
Y_BENCHMARK()
-
-SRCS(
- main.cpp
-)
-
-END()
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/random/benchmark/ya.make b/util/random/benchmark/ya.make
index a4ae9d2728..7d753ae6e7 100644
--- a/util/random/benchmark/ya.make
+++ b/util/random/benchmark/ya.make
@@ -1,10 +1,10 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
-RECURSE(
- prng
- prng/metrics
-)
+
+RECURSE(
+ prng
+ prng/metrics
+)
diff --git a/util/random/common_ops.h b/util/random/common_ops.h
index 373046cdce..602eede351 100644
--- a/util/random/common_ops.h
+++ b/util/random/common_ops.h
@@ -4,31 +4,31 @@
#include <util/system/yassert.h>
namespace NPrivate {
- constexpr double ToRandReal1(const ui32 x) noexcept {
+ constexpr double ToRandReal1(const ui32 x) noexcept {
return x * (double)(1.0 / 4294967295.0);
}
- constexpr double ToRandReal2(const ui32 x) noexcept {
+ constexpr double ToRandReal2(const ui32 x) noexcept {
return x * (double)(1.0 / 4294967296.0);
}
- constexpr double ToRandReal3(const ui32 x) noexcept {
+ constexpr double ToRandReal3(const ui32 x) noexcept {
return ((double)x + 0.5) * (double)(1.0 / 4294967296.0);
}
- constexpr double ToRandReal1(const ui64 x) noexcept {
+ constexpr double ToRandReal1(const ui64 x) noexcept {
return (x >> 11) * (double)(1.0 / 9007199254740991.0);
}
- constexpr double ToRandReal2(const ui64 x) noexcept {
+ constexpr double ToRandReal2(const ui64 x) noexcept {
return (x >> 11) * (double)(1.0 / 9007199254740992.0);
}
- constexpr double ToRandReal3(const ui64 x) noexcept {
+ constexpr double ToRandReal3(const ui64 x) noexcept {
return ((x >> 12) + 0.5) * (double)(1.0 / 4503599627370496.0);
}
- constexpr double ToRandReal4(const ui64 x) noexcept {
+ constexpr double ToRandReal4(const ui64 x) noexcept {
return double(x * (double)(1.0 / 18446744073709551616.0L));
}
@@ -38,7 +38,7 @@ namespace NPrivate {
}
template <class T>
- static constexpr ui64 ToRand64(T&&, ui64 x) noexcept {
+ static constexpr ui64 ToRand64(T&&, ui64 x) noexcept {
return x;
}
@@ -47,7 +47,7 @@ namespace NPrivate {
*/
template <class T, class TRandGen>
static T GenUniform(T max, TRandGen&& gen) {
- Y_VERIFY(max > 0, "Invalid random number range [0, 0)");
+ Y_VERIFY(max > 0, "Invalid random number range [0, 0)");
const T randmax = gen.RandMax() - gen.RandMax() % max;
T rand;
@@ -63,7 +63,7 @@ namespace NPrivate {
template <class TRandType, class T>
struct TCommonRNG {
using TResult = TRandType;
- using result_type = TRandType;
+ using result_type = TRandType;
inline T& Engine() noexcept {
return static_cast<T&>(*this);
@@ -72,11 +72,11 @@ struct TCommonRNG {
static constexpr TResult _Min = TResult(0);
static constexpr TResult _Max = TResult(-1);
- static constexpr TResult RandMax() noexcept {
+ static constexpr TResult RandMax() noexcept {
return _Max;
}
- static constexpr TResult RandMin() noexcept {
+ static constexpr TResult RandMin() noexcept {
return _Min;
}
@@ -120,11 +120,11 @@ struct TCommonRNG {
return Engine().GenRand();
}
- static constexpr TResult max() noexcept {
+ static constexpr TResult max() noexcept {
return T::RandMax();
}
- static constexpr TResult min() noexcept {
+ static constexpr TResult min() noexcept {
return T::RandMin();
}
};
diff --git a/util/random/common_ops_ut.cpp b/util/random/common_ops_ut.cpp
index 4eea0eaf3f..905912bd1e 100644
--- a/util/random/common_ops_ut.cpp
+++ b/util/random/common_ops_ut.cpp
@@ -7,7 +7,7 @@
#include <random>
-Y_UNIT_TEST_SUITE(TestCommonRNG) {
+Y_UNIT_TEST_SUITE(TestCommonRNG) {
template <class T>
struct TRng: public TCommonRNG<T, TRng<T>> {
inline T GenRand() noexcept {
@@ -17,7 +17,7 @@ Y_UNIT_TEST_SUITE(TestCommonRNG) {
T C_ = RandomNumber<T>();
};
- Y_UNIT_TEST(TestUniform1) {
+ Y_UNIT_TEST(TestUniform1) {
TRng<ui32> r;
for (size_t i = 0; i < 1000; ++i) {
@@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(TestCommonRNG) {
}
}
- Y_UNIT_TEST(TestUniform2) {
+ Y_UNIT_TEST(TestUniform2) {
TRng<ui32> r;
for (size_t i = 0; i < 1000; ++i) {
@@ -33,7 +33,7 @@ Y_UNIT_TEST_SUITE(TestCommonRNG) {
}
}
- Y_UNIT_TEST(TestUniform3) {
+ Y_UNIT_TEST(TestUniform3) {
TRng<ui32> r;
for (size_t i = 0; i < 1000; ++i) {
@@ -44,7 +44,7 @@ Y_UNIT_TEST_SUITE(TestCommonRNG) {
}
}
- Y_UNIT_TEST(TestStlCompatibility) {
+ Y_UNIT_TEST(TestStlCompatibility) {
{
TRng<ui32> r;
r.C_ = 17;
diff --git a/util/random/easy_ut.cpp b/util/random/easy_ut.cpp
index d8ac86dd29..d1d024a91f 100644
--- a/util/random/easy_ut.cpp
+++ b/util/random/easy_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TEasyRndInterface) {
- Y_UNIT_TEST(Test1) {
+Y_UNIT_TEST_SUITE(TEasyRndInterface) {
+ Y_UNIT_TEST(Test1) {
{
ui32 x = 0;
diff --git a/util/random/entropy.cpp b/util/random/entropy.cpp
index 7450f390c2..3617edb83d 100644
--- a/util/random/entropy.cpp
+++ b/util/random/entropy.cpp
@@ -5,10 +5,10 @@
#include "shuffle.h"
#include "init_atfork.h"
-#include <util/stream/output.h>
-#include <util/stream/mem.h>
+#include <util/stream/output.h>
+#include <util/stream/mem.h>
#include <util/stream/zlib.h>
-#include <util/stream/buffer.h>
+#include <util/stream/buffer.h>
#include <util/system/fs.h>
#include <util/system/info.h>
@@ -102,7 +102,7 @@ namespace {
};
//not thread-safe
- class TMersenneInput: public IInputStream {
+ class TMersenneInput: public IInputStream {
using TKey = ui64;
using TRnd = TMersenne<TKey>;
@@ -134,7 +134,7 @@ namespace {
TRnd Rnd_;
};
- class TEntropyPoolStream: public IInputStream {
+ class TEntropyPoolStream: public IInputStream {
public:
inline explicit TEntropyPoolStream(const TBuffer& buffer)
: Mi_(buffer)
@@ -154,7 +154,7 @@ namespace {
TBufferedInput Bi_;
};
- struct TSeedStream: public IInputStream {
+ struct TSeedStream: public IInputStream {
size_t DoRead(void* inbuf, size_t len) override {
char* buf = (char*)inbuf;
@@ -184,11 +184,11 @@ namespace {
Reset();
}
- inline IInputStream& EntropyPool() noexcept {
+ inline IInputStream& EntropyPool() noexcept {
return *EP;
}
- inline IInputStream& Seed() noexcept {
+ inline IInputStream& Seed() noexcept {
return SS;
}
@@ -208,11 +208,11 @@ namespace {
using TRandomTraits = TDefaultTraits;
}
-IInputStream& EntropyPool() {
+IInputStream& EntropyPool() {
return TRandomTraits::Instance().EntropyPool();
}
-IInputStream& Seed() {
+IInputStream& Seed() {
return TRandomTraits::Instance().Seed();
}
diff --git a/util/random/entropy.h b/util/random/entropy.h
index 9cb3b2abae..62029c1b63 100644
--- a/util/random/entropy.h
+++ b/util/random/entropy.h
@@ -1,19 +1,19 @@
#pragma once
class TBuffer;
-class IInputStream;
+class IInputStream;
/*
* fast entropy pool, based on good prng, can lock for some time
* initialized with some bits from system entropy pool
* think as /dev/urandom replacement
*/
-IInputStream& EntropyPool();
+IInputStream& EntropyPool();
/*
* fast(non-blocking) entropy pool, useful for seeding PRNGs
*/
-IInputStream& Seed();
+IInputStream& Seed();
/*
* Re-initialize entropy pool - useful after forking in multi-process programs.
diff --git a/util/random/entropy_ut.cpp b/util/random/entropy_ut.cpp
index ed976a9c64..1ff27203f0 100644
--- a/util/random/entropy_ut.cpp
+++ b/util/random/entropy_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TestEntropy) {
- Y_UNIT_TEST(TestSeed) {
+Y_UNIT_TEST_SUITE(TestEntropy) {
+ Y_UNIT_TEST(TestSeed) {
char buf[100];
for (size_t i = 0; i < sizeof(buf); ++i) {
diff --git a/util/random/fast.cpp b/util/random/fast.cpp
index 82d3c9bf76..2f98dfc5d3 100644
--- a/util/random/fast.cpp
+++ b/util/random/fast.cpp
@@ -27,13 +27,13 @@ TFastRng64::TArgs::TArgs(ui64 seed) noexcept {
Seq2 = rng.GenRand();
}
-TFastRng64::TArgs::TArgs(IInputStream& entropy) {
+TFastRng64::TArgs::TArgs(IInputStream& entropy) {
static_assert(sizeof(*this) == 3 * sizeof(ui64), "please, fix me");
entropy.LoadOrFail(this, sizeof(*this));
}
template <class T>
-static inline T Read(IInputStream& in) noexcept {
+static inline T Read(IInputStream& in) noexcept {
T t = T();
in.LoadOrFail(&t, sizeof(t));
@@ -41,12 +41,12 @@ static inline T Read(IInputStream& in) noexcept {
return t;
}
-TFastRng32::TFastRng32(IInputStream& entropy)
+TFastRng32::TFastRng32(IInputStream& entropy)
: TFastRng32(Read<ui64>(entropy), Read<ui32>(entropy))
{
}
-TReallyFastRng32::TReallyFastRng32(IInputStream& entropy)
+TReallyFastRng32::TReallyFastRng32(IInputStream& entropy)
: TReallyFastRng32(Read<ui64>(entropy))
{
}
diff --git a/util/random/fast.h b/util/random/fast.h
index 194524d4b9..ddc5711641 100644
--- a/util/random/fast.h
+++ b/util/random/fast.h
@@ -3,7 +3,7 @@
#include "lcg_engine.h"
#include "common_ops.h"
-#include <util/generic/bitops.h>
+#include <util/generic/bitops.h>
#include <util/system/platform.h>
// based on http://www.pcg-random.org/. See T*FastRng* family below.
@@ -13,14 +13,14 @@ struct TPCGMixer {
const ui32 xorshifted = ((x >> 18u) ^ x) >> 27u;
const ui32 rot = x >> 59u;
- return RotateBitsRight(xorshifted, rot);
+ return RotateBitsRight(xorshifted, rot);
}
};
using TFastRng32Base = TLcgRngBase<TLcgIterator<ui64, ULL(6364136223846793005)>, TPCGMixer>;
using TReallyFastRng32Base = TLcgRngBase<TFastLcgIterator<ui64, ULL(6364136223846793005), ULL(1)>, TPCGMixer>;
-class IInputStream;
+class IInputStream;
struct TFastRng32: public TCommonRNG<ui32, TFastRng32>, public TFastRng32Base {
inline TFastRng32(ui64 seed, ui32 seq)
@@ -28,7 +28,7 @@ struct TFastRng32: public TCommonRNG<ui32, TFastRng32>, public TFastRng32Base {
{
}
- TFastRng32(IInputStream& entropy);
+ TFastRng32(IInputStream& entropy);
};
// faster than TFastRng32, but have only one possible stream sequence
@@ -38,14 +38,14 @@ struct TReallyFastRng32: public TCommonRNG<ui32, TReallyFastRng32>, public TReal
{
}
- TReallyFastRng32(IInputStream& entropy);
+ TReallyFastRng32(IInputStream& entropy);
};
class TFastRng64: public TCommonRNG<ui64, TFastRng64> {
public:
struct TArgs {
TArgs(ui64 seed) noexcept;
- TArgs(IInputStream& entropy);
+ TArgs(IInputStream& entropy);
ui64 Seed1;
ui64 Seed2;
@@ -58,7 +58,7 @@ public:
/*
* simplify constructions like
* TFastRng64 rng(17);
- * TFastRng64 rng(Seek()); //from any IInputStream
+ * TFastRng64 rng(Seek()); //from any IInputStream
*/
inline TFastRng64(const TArgs& args) noexcept
: TFastRng64(args.Seed1, args.Seq1, args.Seed2, args.Seq2)
diff --git a/util/random/fast_ut.cpp b/util/random/fast_ut.cpp
index a513a973b1..60994a98b0 100644
--- a/util/random/fast_ut.cpp
+++ b/util/random/fast_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TTestFastRng) {
- Y_UNIT_TEST(Test1) {
+Y_UNIT_TEST_SUITE(TTestFastRng) {
+ Y_UNIT_TEST(Test1) {
TFastRng32 rng1(17, 0);
TReallyFastRng32 rng2(17);
@@ -35,15 +35,15 @@ Y_UNIT_TEST_SUITE(TTestFastRng) {
75,
};
- Y_UNIT_TEST(Test2) {
+ Y_UNIT_TEST(Test2) {
TFastRng64 rng(0, 1, 2, 3);
- for (auto& i : R1) {
- UNIT_ASSERT_VALUES_EQUAL(rng.Uniform(100u), i);
+ for (auto& i : R1) {
+ UNIT_ASSERT_VALUES_EQUAL(rng.Uniform(100u), i);
}
}
- Y_UNIT_TEST(TestAdvance) {
+ Y_UNIT_TEST(TestAdvance) {
TReallyFastRng32 rng1(17);
TReallyFastRng32 rng2(17);
for (size_t i = 0; i < 100; i++) {
@@ -61,7 +61,7 @@ Y_UNIT_TEST_SUITE(TTestFastRng) {
UNIT_ASSERT_VALUES_EQUAL(rng3.GenRand(), rng4.GenRand());
}
- Y_UNIT_TEST(TestAdvanceBoundaries) {
+ Y_UNIT_TEST(TestAdvanceBoundaries) {
TReallyFastRng32 rng1(17);
TReallyFastRng32 rng2(17);
TReallyFastRng32 rng3(17);
@@ -71,7 +71,7 @@ Y_UNIT_TEST_SUITE(TTestFastRng) {
UNIT_ASSERT_VALUES_EQUAL(rng1.GenRand(), rng3.GenRand());
}
- Y_UNIT_TEST(TestCopy) {
+ Y_UNIT_TEST(TestCopy) {
TReallyFastRng32 r1(1);
TReallyFastRng32 r2(2);
@@ -82,13 +82,13 @@ Y_UNIT_TEST_SUITE(TTestFastRng) {
UNIT_ASSERT_VALUES_EQUAL(r1.GenRand(), r2.GenRand());
}
- Y_UNIT_TEST(Test3) {
+ Y_UNIT_TEST(Test3) {
TFastRng64 rng(17);
UNIT_ASSERT_VALUES_EQUAL(rng.GenRand(), ULL(14895365814383052362));
}
- Y_UNIT_TEST(TestCompile) {
+ Y_UNIT_TEST(TestCompile) {
TFastRng<ui32> rng1(1);
TFastRng<ui64> rng2(2);
TFastRng<size_t> rng3(3);
@@ -103,14 +103,14 @@ Y_UNIT_TEST_SUITE(TTestFastRng) {
"But apparently I made a blunder here -"
"Doha does not warm ... Absolutely.";
- Y_UNIT_TEST(TestStreamCtor1) {
+ Y_UNIT_TEST(TestStreamCtor1) {
TMemoryInput mi(RNG_DATA, strlen(RNG_DATA));
TFastRng<ui32> rng(mi);
UNIT_ASSERT_VALUES_EQUAL(rng.GenRand(), 1449109131u);
}
- Y_UNIT_TEST(TestStreamCtor2) {
+ Y_UNIT_TEST(TestStreamCtor2) {
TMemoryInput mi(RNG_DATA, strlen(RNG_DATA));
TFastRng<ui64> rng(mi);
diff --git a/util/random/lcg_engine.h b/util/random/lcg_engine.h
index bee44db16c..08cc93c845 100644
--- a/util/random/lcg_engine.h
+++ b/util/random/lcg_engine.h
@@ -15,7 +15,7 @@ template <typename T, T A, T C>
struct TFastLcgIterator {
static_assert(C % 2 == 1, "C must be odd");
- static constexpr T Iterate(T x) noexcept {
+ static constexpr T Iterate(T x) noexcept {
return x * A + C;
}
diff --git a/util/random/mersenne.h b/util/random/mersenne.h
index 567fafc362..b2044604ac 100644
--- a/util/random/mersenne.h
+++ b/util/random/mersenne.h
@@ -19,7 +19,7 @@ namespace NPrivate {
};
}
-class IInputStream;
+class IInputStream;
template <class T>
class TMersenne: public TCommonRNG<T, TMersenne<T>>, public ::NPrivate::TMersenneTraits<T>::TImpl {
@@ -34,7 +34,7 @@ public:
{
}
- inline TMersenne(IInputStream& pool)
+ inline TMersenne(IInputStream& pool)
: TBase(pool)
{
}
diff --git a/util/random/mersenne32.cpp b/util/random/mersenne32.cpp
index 04a2af59e4..cb8aad8b03 100644
--- a/util/random/mersenne32.cpp
+++ b/util/random/mersenne32.cpp
@@ -83,13 +83,13 @@ void TMersenne32::InitNext() noexcept {
mti = 0;
}
-TMersenne32::TMersenne32(IInputStream& input)
+TMersenne32::TMersenne32(IInputStream& input)
: mti(N + 1)
{
ui32 buf[128];
input.LoadOrFail(buf, sizeof(buf));
- InitByArray(buf, Y_ARRAY_SIZE(buf));
+ InitByArray(buf, Y_ARRAY_SIZE(buf));
}
#undef M
diff --git a/util/random/mersenne32.h b/util/random/mersenne32.h
index 75096e68a0..861f3a3d38 100644
--- a/util/random/mersenne32.h
+++ b/util/random/mersenne32.h
@@ -2,11 +2,11 @@
#include <util/system/defaults.h>
-class IInputStream;
+class IInputStream;
namespace NPrivate {
class TMersenne32 {
- static constexpr int N = 624;
+ static constexpr int N = 624;
public:
inline TMersenne32(ui32 s = 19650218UL) noexcept
@@ -21,7 +21,7 @@ namespace NPrivate {
InitByArray(init_key, key_length);
}
- TMersenne32(IInputStream& input);
+ TMersenne32(IInputStream& input);
inline ui32 GenRand() noexcept {
if (mti >= N) {
diff --git a/util/random/mersenne64.cpp b/util/random/mersenne64.cpp
index 9426e58e5e..4ede2c6dca 100644
--- a/util/random/mersenne64.cpp
+++ b/util/random/mersenne64.cpp
@@ -85,13 +85,13 @@ void TMersenne64::InitNext() noexcept {
mti = 0;
}
-TMersenne64::TMersenne64(IInputStream& input)
+TMersenne64::TMersenne64(IInputStream& input)
: mti(NN + 1)
{
ui64 buf[128];
input.LoadOrFail(buf, sizeof(buf));
- InitByArray(buf, Y_ARRAY_SIZE(buf));
+ InitByArray(buf, Y_ARRAY_SIZE(buf));
}
#undef MM
diff --git a/util/random/mersenne64.h b/util/random/mersenne64.h
index db40a939ac..12ca43b6af 100644
--- a/util/random/mersenne64.h
+++ b/util/random/mersenne64.h
@@ -2,11 +2,11 @@
#include <util/system/defaults.h>
-class IInputStream;
+class IInputStream;
namespace NPrivate {
class TMersenne64 {
- static constexpr int NN = 312;
+ static constexpr int NN = 312;
public:
inline TMersenne64(ui64 s = ULL(19650218))
@@ -21,7 +21,7 @@ namespace NPrivate {
InitByArray(keys, len);
}
- TMersenne64(IInputStream& input);
+ TMersenne64(IInputStream& input);
inline ui64 GenRand() noexcept {
if (mti >= NN) {
diff --git a/util/random/mersenne_ut.cpp b/util/random/mersenne_ut.cpp
index 27bd979deb..a4b84efa3d 100644
--- a/util/random/mersenne_ut.cpp
+++ b/util/random/mersenne_ut.cpp
@@ -2,11 +2,11 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#define UI32(x) x##ul
-Y_UNIT_TEST_SUITE(TMersenneRndTest) {
+Y_UNIT_TEST_SUITE(TMersenneRndTest) {
template <class T>
inline void Test(const T* res, size_t len) {
TMersenne<T> m;
@@ -16,7 +16,7 @@ Y_UNIT_TEST_SUITE(TMersenneRndTest) {
}
}
- Y_UNIT_TEST(Test32) {
+ Y_UNIT_TEST(Test32) {
const ui32 res[] = {
UI32(2325592414),
UI32(482149846),
@@ -30,10 +30,10 @@ Y_UNIT_TEST_SUITE(TMersenneRndTest) {
UI32(3882134983),
};
- Test<ui32>(res, Y_ARRAY_SIZE(res));
+ Test<ui32>(res, Y_ARRAY_SIZE(res));
}
- Y_UNIT_TEST(Test64) {
+ Y_UNIT_TEST(Test64) {
const ui64 res[] = {
ULL(13735441942630277712),
ULL(10468394322237346228),
@@ -47,10 +47,10 @@ Y_UNIT_TEST_SUITE(TMersenneRndTest) {
ULL(11231499428520958715),
};
- Test<ui64>(res, Y_ARRAY_SIZE(res));
+ Test<ui64>(res, Y_ARRAY_SIZE(res));
}
- Y_UNIT_TEST(TestGenRand64) {
+ Y_UNIT_TEST(TestGenRand64) {
TMersenne<ui32> rng;
for (size_t i = 0; i < 100; ++i) {
@@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TMersenneRndTest) {
}
}
- Y_UNIT_TEST(TestCopy32) {
+ Y_UNIT_TEST(TestCopy32) {
TMersenne<ui32> r1(1);
TMersenne<ui32> r2(2);
@@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TMersenneRndTest) {
UNIT_ASSERT_VALUES_EQUAL(r1.GenRand(), r2.GenRand());
}
- Y_UNIT_TEST(TestCopy64) {
+ Y_UNIT_TEST(TestCopy64) {
TMersenne<ui64> r1(1);
TMersenne<ui64> r2(2);
diff --git a/util/random/normal_ut.cpp b/util/random/normal_ut.cpp
index 23311c8079..42b6cc4ba2 100644
--- a/util/random/normal_ut.cpp
+++ b/util/random/normal_ut.cpp
@@ -7,8 +7,8 @@
#include <functional>
-Y_UNIT_TEST_SUITE(TestNormalDistribution) {
- Y_UNIT_TEST(TestDefined) {
+Y_UNIT_TEST_SUITE(TestNormalDistribution) {
+ Y_UNIT_TEST(TestDefined) {
volatile auto x = NormalRandom<float>(0, 1) + NormalRandom<double>(0, 1) + NormalRandom<long double>(0, 1);
(void)x;
@@ -45,7 +45,7 @@ Y_UNIT_TEST_SUITE(TestNormalDistribution) {
UNIT_ASSERT_DOUBLES_EQUAL(d, dd, (d + 1) * 0.05);
}
- Y_UNIT_TEST(Test1) {
+ Y_UNIT_TEST(Test1) {
TestMD<float>(&StdNormalRandom<float>, 0, 1);
TestMD<double>(&StdNormalRandom<double>, 0, 1);
TestMD<long double>(&StdNormalRandom<long double>, 0, 1);
@@ -67,13 +67,13 @@ Y_UNIT_TEST_SUITE(TestNormalDistribution) {
};
}
- Y_UNIT_TEST(Test2) {
+ Y_UNIT_TEST(Test2) {
TestMD<float>(GenFunc1<float>(2, 3), 2, 3);
TestMD<double>(GenFunc1<double>(3, 4), 3, 4);
TestMD<long double>(GenFunc1<long double>(4, 5), 4, 5);
}
- Y_UNIT_TEST(Test3) {
+ Y_UNIT_TEST(Test3) {
TestMD<float>(GenFunc2<float>(20, 30), 20, 30);
TestMD<double>(GenFunc2<double>(30, 40), 30, 40);
TestMD<long double>(GenFunc2<long double>(40, 50), 40, 50);
diff --git a/util/random/random_ut.cpp b/util/random/random_ut.cpp
index 1f52efe2fa..30427676f3 100644
--- a/util/random/random_ut.cpp
+++ b/util/random/random_ut.cpp
@@ -10,7 +10,7 @@ static inline void AssertRange(T v, T r1, T r2) {
UNIT_ASSERT(v < r2);
}
-Y_UNIT_TEST_SUITE(TRandomNumberTest) {
+Y_UNIT_TEST_SUITE(TRandomNumberTest) {
template <typename T>
void TestAll(T n) {
for (T i = 0; i < n; ++i) {
@@ -49,32 +49,32 @@ Y_UNIT_TEST_SUITE(TRandomNumberTest) {
TestSome<T>(Max<T>() - 22222);
}
- Y_UNIT_TEST(TestWithLimit) {
+ Y_UNIT_TEST(TestWithLimit) {
TestType<unsigned short>();
TestType<unsigned int>();
TestType<unsigned long>();
TestType<unsigned long long>();
}
- Y_UNIT_TEST(TestRandomNumberFloat) {
+ Y_UNIT_TEST(TestRandomNumberFloat) {
for (size_t i = 0; i < 1000; ++i) {
AssertRange<float>(RandomNumber<float>(), 0.0, 1.0);
}
}
- Y_UNIT_TEST(TestRandomNumberDouble) {
+ Y_UNIT_TEST(TestRandomNumberDouble) {
for (size_t i = 0; i < 1000; ++i) {
AssertRange<double>(RandomNumber<double>(), 0.0, 1.0);
}
}
- Y_UNIT_TEST(TestRandomNumberLongDouble) {
+ Y_UNIT_TEST(TestRandomNumberLongDouble) {
for (size_t i = 0; i < 1000; ++i) {
AssertRange<long double>(RandomNumber<long double>(), 0.0, 1.0);
}
}
- Y_UNIT_TEST(TestBoolean) {
+ Y_UNIT_TEST(TestBoolean) {
while (RandomNumber<bool>()) {
}
while (!RandomNumber<bool>()) {
diff --git a/util/random/shuffle_ut.cpp b/util/random/shuffle_ut.cpp
index 5da99b0b48..87cbae94c0 100644
--- a/util/random/shuffle_ut.cpp
+++ b/util/random/shuffle_ut.cpp
@@ -6,7 +6,7 @@
#include <util/generic/ylimits.h>
-Y_UNIT_TEST_SUITE(TRandUtilsTest) {
+Y_UNIT_TEST_SUITE(TRandUtilsTest) {
template <typename... A>
static void TestRange(A&&... args) {
TString s0, s1;
@@ -55,19 +55,19 @@ Y_UNIT_TEST_SUITE(TRandUtilsTest) {
TestRange(prng);
}
- Y_UNIT_TEST(TestShuffleMersenne32) {
+ Y_UNIT_TEST(TestShuffleMersenne32) {
TMersenne<ui32> prng(24);
TestIter(prng);
}
- Y_UNIT_TEST(TestShuffleFast32) {
+ Y_UNIT_TEST(TestShuffleFast32) {
TFastRng32 prng(24, 0);
TestIter(prng);
}
- Y_UNIT_TEST(TestShuffleFast64) {
+ Y_UNIT_TEST(TestShuffleFast64) {
TFastRng64 prng(24, 0, 25, 1);
TestIter(prng);
diff --git a/util/str_stl.h b/util/str_stl.h
index d91ef1a7cb..f1e137181d 100644
--- a/util/str_stl.h
+++ b/util/str_stl.h
@@ -46,15 +46,15 @@ namespace NHashPrivate {
return NumericHash(t);
}
};
-
- template <typename C>
- struct TStringHash {
- using is_transparent = void;
-
- inline size_t operator()(const TBasicStringBuf<C> s) const noexcept {
+
+ template <typename C>
+ struct TStringHash {
+ using is_transparent = void;
+
+ inline size_t operator()(const TBasicStringBuf<C> s) const noexcept {
return NHashPrivate::ComputeStringHash(s.data(), s.size());
- }
- };
+ }
+ };
}
template <class T>
@@ -88,18 +88,18 @@ template <>
struct hash<TUtf16String>: ::NHashPrivate::TStringHash<wchar16> {
};
-template <>
+template <>
struct THash<TWtringBuf>: ::NHashPrivate::TStringHash<wchar16> {
-};
+};
-template <>
+template <>
struct hash<TUtf32String>: ::NHashPrivate::TStringHash<wchar32> {
-};
-
-template <>
+};
+
+template <>
struct THash<TUtf32StringBuf>: ::NHashPrivate::TStringHash<wchar32> {
-};
-
+};
+
template <class C, class T, class A>
struct hash<std::basic_string<C, T, A>>: ::NHashPrivate::TStringHash<C> {
};
@@ -221,7 +221,7 @@ struct TCIEqualTo<const char*> {
template <>
struct TCIEqualTo<TStringBuf> {
- inline bool operator()(const TStringBuf a, const TStringBuf b) const {
+ inline bool operator()(const TStringBuf a, const TStringBuf b) const {
return a.size() == b.size() && strnicmp(a.data(), b.data(), a.size()) == 0;
}
};
diff --git a/util/stream/aligned.cpp b/util/stream/aligned.cpp
index 2b5ec6d41b..2fd12d15b7 100644
--- a/util/stream/aligned.cpp
+++ b/util/stream/aligned.cpp
@@ -18,7 +18,7 @@ size_t TAlignedInput::DoReadTo(TString& st, char ch) {
return ret;
}
-ui64 TAlignedInput::DoReadAll(IOutputStream& out) {
+ui64 TAlignedInput::DoReadAll(IOutputStream& out) {
ui64 ret = Stream_->ReadAll(out);
Position_ += ret;
return ret;
diff --git a/util/stream/aligned.h b/util/stream/aligned.h
index 672ea25494..70e7be05a9 100644
--- a/util/stream/aligned.h
+++ b/util/stream/aligned.h
@@ -15,9 +15,9 @@
* Proxy input stream that provides additional functions that make reading
* aligned data easier.
*/
-class TAlignedInput: public IInputStream {
+class TAlignedInput: public IInputStream {
public:
- TAlignedInput(IInputStream* s)
+ TAlignedInput(IInputStream* s)
: Stream_(s)
, Position_(0)
{
@@ -30,7 +30,7 @@ public:
* @param alignment Alignment. Must be a power of 2.
*/
void Align(size_t alignment = sizeof(void*)) {
- Y_ASSERT(IsPowerOf2(alignment));
+ Y_ASSERT(IsPowerOf2(alignment));
if (Position_ & (alignment - 1)) {
size_t len = alignment - (Position_ & (alignment - 1));
@@ -45,10 +45,10 @@ private:
size_t DoRead(void* ptr, size_t len) override;
size_t DoSkip(size_t len) override;
size_t DoReadTo(TString& st, char ch) override;
- ui64 DoReadAll(IOutputStream& out) override;
+ ui64 DoReadAll(IOutputStream& out) override;
private:
- IInputStream* Stream_;
+ IInputStream* Stream_;
ui64 Position_;
};
@@ -56,9 +56,9 @@ private:
* Proxy output stream that provides additional functions that make writing
* aligned data easier.
*/
-class TAlignedOutput: public IOutputStream {
+class TAlignedOutput: public IOutputStream {
public:
- TAlignedOutput(IOutputStream* s)
+ TAlignedOutput(IOutputStream* s)
: Stream_(s)
, Position_(0)
{
@@ -78,10 +78,10 @@ public:
* @param alignment Alignment. Must be a power of 2.
*/
void Align(size_t alignment = sizeof(void*)) {
- Y_ASSERT(IsPowerOf2(alignment));
+ Y_ASSERT(IsPowerOf2(alignment));
static char unused[sizeof(void*) * 2];
- Y_ASSERT(alignment <= sizeof(unused));
+ Y_ASSERT(alignment <= sizeof(unused));
if (Position_ & (alignment - 1)) {
DoWrite(unused, alignment - (Position_ & (alignment - 1)));
@@ -92,7 +92,7 @@ private:
void DoWrite(const void* ptr, size_t len) override;
private:
- IOutputStream* Stream_;
+ IOutputStream* Stream_;
ui64 Position_;
};
diff --git a/util/stream/aligned_ut.cpp b/util/stream/aligned_ut.cpp
index b8eaeea437..e980d05cf7 100644
--- a/util/stream/aligned_ut.cpp
+++ b/util/stream/aligned_ut.cpp
@@ -2,7 +2,7 @@
#include <library/cpp/testing/unittest/registar.h>
-class TNastyInputStream: public IInputStream {
+class TNastyInputStream: public IInputStream {
public:
TNastyInputStream()
: Pos_(0)
@@ -33,8 +33,8 @@ private:
size_t Pos_;
};
-Y_UNIT_TEST_SUITE(TAlignedTest) {
- Y_UNIT_TEST(AlignInput) {
+Y_UNIT_TEST_SUITE(TAlignedTest) {
+ Y_UNIT_TEST(AlignInput) {
TNastyInputStream input0;
TAlignedInput alignedInput(&input0);
diff --git a/util/stream/buffer.h b/util/stream/buffer.h
index 3520be22de..9dc99dbe49 100644
--- a/util/stream/buffer.h
+++ b/util/stream/buffer.h
@@ -58,7 +58,7 @@ private:
/**
* Input stream that reads from an external `TBuffer`.
*/
-class TBufferInput: public IZeroCopyInputFastReadTo {
+class TBufferInput: public IZeroCopyInputFastReadTo {
public:
/**
* Constructs a stream that reads from an external buffer. It's up to the
diff --git a/util/stream/buffer_ut.cpp b/util/stream/buffer_ut.cpp
index 4958f3baca..3494696190 100644
--- a/util/stream/buffer_ut.cpp
+++ b/util/stream/buffer_ut.cpp
@@ -8,8 +8,8 @@
#include "str.h"
-Y_UNIT_TEST_SUITE(TBufferTest) {
- Y_UNIT_TEST(Transfer) {
+Y_UNIT_TEST_SUITE(TBufferTest) {
+ Y_UNIT_TEST(Transfer) {
TBuffer buffer("razrazraz", 9);
TBufferInput input(buffer);
@@ -21,7 +21,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
UNIT_ASSERT_VALUES_EQUAL(output.Str(), "razraz");
}
- Y_UNIT_TEST(ReadTo) {
+ Y_UNIT_TEST(ReadTo) {
TBuffer buffer("1234567890", 10);
TBufferInput input(buffer);
@@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
UNIT_ASSERT(0 == memcmp(buffer.data(), str.begin(), buffer.size()));
}
- Y_UNIT_TEST(Write) {
+ Y_UNIT_TEST(Write) {
TBuffer buffer;
TBufferOutput output(buffer);
output << "1"
@@ -75,7 +75,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
buffer.size()));
}
- Y_UNIT_TEST(WriteChars) {
+ Y_UNIT_TEST(WriteChars) {
TBuffer buffer;
TBufferOutput output(buffer);
output << '1' << '2' << '3' << '4' << '5' << '6' << '7' << '8' << '9' << '0';
diff --git a/util/stream/buffered.cpp b/util/stream/buffered.cpp
index 230b743688..a00e592e1c 100644
--- a/util/stream/buffered.cpp
+++ b/util/stream/buffered.cpp
@@ -7,9 +7,9 @@
class TBufferedInput::TImpl: public TAdditionalStorage<TImpl> {
public:
- inline TImpl(IInputStream* slave)
+ inline TImpl(IInputStream* slave)
: Slave_(slave)
- , MemInput_(nullptr, 0)
+ , MemInput_(nullptr, 0)
{
}
@@ -99,7 +99,7 @@ public:
return ret;
}
- inline void Reset(IInputStream* slave) {
+ inline void Reset(IInputStream* slave) {
Slave_ = slave;
}
@@ -113,11 +113,11 @@ private:
}
private:
- IInputStream* Slave_;
+ IInputStream* Slave_;
TMemoryInput MemInput_;
};
-TBufferedInput::TBufferedInput(IInputStream* slave, size_t buflen)
+TBufferedInput::TBufferedInput(IInputStream* slave, size_t buflen)
: Impl_(new (buflen) TImpl(slave))
{
}
@@ -143,13 +143,13 @@ size_t TBufferedInput::DoReadTo(TString& st, char ch) {
return Impl_->ReadTo(st, ch);
}
-void TBufferedInput::Reset(IInputStream* slave) {
+void TBufferedInput::Reset(IInputStream* slave) {
Impl_->Reset(slave);
}
class TBufferedOutputBase::TImpl {
public:
- inline TImpl(IOutputStream* slave)
+ inline TImpl(IOutputStream* slave)
: Slave_(slave)
, MemOut_(nullptr, 0)
, PropagateFlush_(false)
@@ -191,7 +191,7 @@ public:
const size_t good_len = DownToBufferGranularity(full_len);
const size_t write_from_buf = good_len - stored;
- using TPart = IOutputStream::TPart;
+ using TPart = IOutputStream::TPart;
alignas(TPart) char data[2 * sizeof(TPart)];
TPart* parts = reinterpret_cast<TPart*>(data);
@@ -282,7 +282,7 @@ private:
virtual size_t Len() const noexcept = 0;
private:
- IOutputStream* Slave_;
+ IOutputStream* Slave_;
TMemoryOutput MemOut_;
bool PropagateFlush_;
bool PropagateFinish_;
@@ -290,7 +290,7 @@ private:
namespace {
struct TSimpleImpl: public TBufferedOutputBase::TImpl, public TAdditionalStorage<TSimpleImpl> {
- inline TSimpleImpl(IOutputStream* slave)
+ inline TSimpleImpl(IOutputStream* slave)
: TBufferedOutputBase::TImpl(slave)
{
Reset();
@@ -315,7 +315,7 @@ namespace {
Step = 4096
};
- inline TAdaptiveImpl(IOutputStream* slave)
+ inline TAdaptiveImpl(IOutputStream* slave)
: TBufferedOutputBase::TImpl(slave)
, N_(0)
{
@@ -346,12 +346,12 @@ namespace {
};
}
-TBufferedOutputBase::TBufferedOutputBase(IOutputStream* slave)
+TBufferedOutputBase::TBufferedOutputBase(IOutputStream* slave)
: Impl_(new TAdaptiveImpl(slave))
{
}
-TBufferedOutputBase::TBufferedOutputBase(IOutputStream* slave, size_t buflen)
+TBufferedOutputBase::TBufferedOutputBase(IOutputStream* slave, size_t buflen)
: Impl_(new (buflen) TSimpleImpl(slave))
{
}
@@ -413,14 +413,14 @@ void TBufferedOutputBase::SetFinishPropagateMode(bool propagate) noexcept {
}
}
-TBufferedOutput::TBufferedOutput(IOutputStream* slave, size_t buflen)
+TBufferedOutput::TBufferedOutput(IOutputStream* slave, size_t buflen)
: TBufferedOutputBase(slave, buflen)
{
}
TBufferedOutput::~TBufferedOutput() = default;
-TAdaptiveBufferedOutput::TAdaptiveBufferedOutput(IOutputStream* slave)
+TAdaptiveBufferedOutput::TAdaptiveBufferedOutput(IOutputStream* slave)
: TBufferedOutputBase(slave)
{
}
diff --git a/util/stream/buffered.h b/util/stream/buffered.h
index 3e57740e24..0847186141 100644
--- a/util/stream/buffered.h
+++ b/util/stream/buffered.h
@@ -20,9 +20,9 @@
* Note that it does not claim ownership of the underlying stream, so it's up
* to the user to free it.
*/
-class TBufferedInput: public IZeroCopyInput {
+class TBufferedInput: public IZeroCopyInput {
public:
- TBufferedInput(IInputStream* slave, size_t buflen = 8192);
+ TBufferedInput(IInputStream* slave, size_t buflen = 8192);
TBufferedInput(TBufferedInput&&) noexcept;
TBufferedInput& operator=(TBufferedInput&&) noexcept;
@@ -35,7 +35,7 @@ public:
*
* @param slave New underlying stream.
*/
- void Reset(IInputStream* slave);
+ void Reset(IInputStream* slave);
protected:
size_t DoRead(void* buf, size_t len) override;
@@ -69,7 +69,7 @@ public:
*
* @param slave Underlying stream.
*/
- TBufferedOutputBase(IOutputStream* slave);
+ TBufferedOutputBase(IOutputStream* slave);
/**
* Constructs a buffered stream with the given size of the buffer.
@@ -77,7 +77,7 @@ public:
* @param slave Underlying stream.
* @param buflen Size of the buffer.
*/
- TBufferedOutputBase(IOutputStream* slave, size_t buflen);
+ TBufferedOutputBase(IOutputStream* slave, size_t buflen);
TBufferedOutputBase(TBufferedOutputBase&&) noexcept;
TBufferedOutputBase& operator=(TBufferedOutputBase&&) noexcept;
@@ -129,7 +129,7 @@ private:
*/
class TBufferedOutput: public TBufferedOutputBase {
public:
- TBufferedOutput(IOutputStream* slave, size_t buflen = 8192);
+ TBufferedOutput(IOutputStream* slave, size_t buflen = 8192);
~TBufferedOutput() override;
TBufferedOutput(TBufferedOutput&&) noexcept = default;
@@ -144,7 +144,7 @@ public:
*/
class TAdaptiveBufferedOutput: public TBufferedOutputBase {
public:
- TAdaptiveBufferedOutput(IOutputStream* slave);
+ TAdaptiveBufferedOutput(IOutputStream* slave);
~TAdaptiveBufferedOutput() override;
TAdaptiveBufferedOutput(TAdaptiveBufferedOutput&&) noexcept = default;
@@ -153,7 +153,7 @@ public:
namespace NPrivate {
struct TMyBufferedOutput: public TBufferedOutput {
- inline TMyBufferedOutput(IOutputStream* slave, size_t buflen)
+ inline TMyBufferedOutput(IOutputStream* slave, size_t buflen)
: TBufferedOutput(slave, buflen)
{
SetFinishPropagateMode(true);
@@ -162,7 +162,7 @@ namespace NPrivate {
template <class T>
struct TBufferedStreamFor {
- using TResult = std::conditional_t<std::is_base_of<IInputStream, T>::value, TBufferedInput, TMyBufferedOutput>;
+ using TResult = std::conditional_t<std::is_base_of<IInputStream, T>::value, TBufferedInput, TMyBufferedOutput>;
};
}
diff --git a/util/stream/buffered_ut.cpp b/util/stream/buffered_ut.cpp
index 4d97247175..41d2fc3030 100644
--- a/util/stream/buffered_ut.cpp
+++ b/util/stream/buffered_ut.cpp
@@ -5,7 +5,7 @@
#include <util/generic/string.h>
#include <util/random/mersenne.h>
-Y_UNIT_TEST_SUITE(TestBufferedIO) {
+Y_UNIT_TEST_SUITE(TestBufferedIO) {
template <class TOut>
inline void Run(TOut&& out) {
TMersenne<ui64> r;
@@ -22,7 +22,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
}
}
- Y_UNIT_TEST(TestEqual) {
+ Y_UNIT_TEST(TestEqual) {
TString s1;
TString s2;
@@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
UNIT_ASSERT_VALUES_EQUAL(s1, s2);
}
- Y_UNIT_TEST(Test1) {
+ Y_UNIT_TEST(Test1) {
TString s;
TBuffered<TStringOutput>(100, s).Write("1", 1);
@@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
UNIT_ASSERT_VALUES_EQUAL(s, "1");
}
- Y_UNIT_TEST(Test2) {
+ Y_UNIT_TEST(Test2) {
TString s;
TBuffered<TStringOutput>(1, s).Write("12", 2);
@@ -48,7 +48,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
UNIT_ASSERT_VALUES_EQUAL(s, "12");
}
- Y_UNIT_TEST(Test3) {
+ Y_UNIT_TEST(Test3) {
TString s;
auto&& b = TBuffered<TStringOutput>(1, s);
@@ -60,7 +60,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
UNIT_ASSERT_VALUES_EQUAL(s, "112");
}
- Y_UNIT_TEST(Test4) {
+ Y_UNIT_TEST(Test4) {
TString s;
auto&& b = TBuffered<TStringOutput>(1, s);
@@ -107,7 +107,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
UNIT_ASSERT_STRINGS_EQUAL(str1, str2);
}
- Y_UNIT_TEST(TestInput) {
+ Y_UNIT_TEST(TestInput) {
TString s("0123456789abcdefghijklmn");
TBuffered<TStringInput> in(5, s);
char c;
@@ -128,7 +128,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
UNIT_ASSERT_VALUES_EQUAL(in.Skip(6), 3); //24 eof
}
- Y_UNIT_TEST(TestReadTo) {
+ Y_UNIT_TEST(TestReadTo) {
TString s("0123456789abc");
TBuffered<TStringInput> in(2, s);
TString t;
diff --git a/util/stream/debug.cpp b/util/stream/debug.cpp
index 3ccb1abf38..afd5b3e1c7 100644
--- a/util/stream/debug.cpp
+++ b/util/stream/debug.cpp
@@ -31,7 +31,7 @@ namespace {
}
}
- IOutputStream* Out;
+ IOutputStream* Out;
int Level;
};
}
@@ -41,7 +41,7 @@ struct TSingletonTraits<TDbgSelector> {
static constexpr size_t Priority = 8;
};
-IOutputStream& StdDbgStream() noexcept {
+IOutputStream& StdDbgStream() noexcept {
return *(Singleton<TDbgSelector>()->Out);
}
diff --git a/util/stream/debug.h b/util/stream/debug.h
index 6faaf8d7c1..92d6d4b42d 100644
--- a/util/stream/debug.h
+++ b/util/stream/debug.h
@@ -10,7 +10,7 @@
/**
* Debug output stream. Writes into `stderr`.
*/
-class TDebugOutput: public IOutputStream {
+class TDebugOutput: public IOutputStream {
public:
inline TDebugOutput() noexcept = default;
~TDebugOutput() override = default;
@@ -26,7 +26,7 @@ private:
* @returns Standard debug stream.
* @see Cdbg
*/
-IOutputStream& StdDbgStream() noexcept;
+IOutputStream& StdDbgStream() noexcept;
/**
* This function returns the current debug level as set via `DBGOUT` environment
diff --git a/util/stream/direct_io.h b/util/stream/direct_io.h
index dff843b35c..2e1f2e07dd 100644
--- a/util/stream/direct_io.h
+++ b/util/stream/direct_io.h
@@ -4,7 +4,7 @@
#include "output.h"
#include <util/system/direct_io.h>
-class TRandomAccessFileInput: public IInputStream {
+class TRandomAccessFileInput: public IInputStream {
public:
TRandomAccessFileInput(TDirectIOBufferedFile& file, ui64 position);
@@ -17,7 +17,7 @@ private:
ui64 Position;
};
-class TRandomAccessFileOutput: public IOutputStream {
+class TRandomAccessFileOutput: public IOutputStream {
public:
TRandomAccessFileOutput(TDirectIOBufferedFile& file);
diff --git a/util/stream/direct_io_ut.cpp b/util/stream/direct_io_ut.cpp
index 04784f5b0d..01d09db232 100644
--- a/util/stream/direct_io_ut.cpp
+++ b/util/stream/direct_io_ut.cpp
@@ -1,71 +1,71 @@
#include <library/cpp/testing/unittest/registar.h>
#include <util/generic/string.h>
-#include <util/generic/array_size.h>
-#include <util/system/env.h>
+#include <util/generic/array_size.h>
+#include <util/system/env.h>
-#include "buffered.h"
-#include "direct_io.h"
+#include "buffered.h"
+#include "direct_io.h"
-Y_UNIT_TEST_SUITE(TDirectIOTests) {
+Y_UNIT_TEST_SUITE(TDirectIOTests) {
// Decrease numBufToWrite further if tests continue to time out
static void Y_NO_INLINE Test(EOpenMode mode, size_t numBufToWrite) {
- const char TEMPLATE[] = "qwertyuiopQWERTYUIOPasdfghjklASD";
- const auto TEMPLATE_SIZE = Y_ARRAY_SIZE(TEMPLATE) - 1;
- static_assert(TEMPLATE_SIZE > 0, "must be greater than zero");
-
- const size_t BUFFER_SIZE = 32 * 1024;
- static_assert(0 == BUFFER_SIZE % TEMPLATE_SIZE, "must be divisible");
-
- const size_t CHUNK_SIZE_TO_READ = 512;
- static_assert(0 == CHUNK_SIZE_TO_READ % TEMPLATE_SIZE, "must be divisible");
-
- // filling buffer
- // TEMPLATE|TEMPLATE|TEMPLATE|...
- auto&& buffer = TBuffer{BUFFER_SIZE};
- for (size_t i = 0; i < BUFFER_SIZE / TEMPLATE_SIZE; ++i) {
- buffer.Append(TEMPLATE, TEMPLATE_SIZE);
- }
-
- // filling file
- // TEMPLATE|TEMPLATE|TEMPLATE|...
+ const char TEMPLATE[] = "qwertyuiopQWERTYUIOPasdfghjklASD";
+ const auto TEMPLATE_SIZE = Y_ARRAY_SIZE(TEMPLATE) - 1;
+ static_assert(TEMPLATE_SIZE > 0, "must be greater than zero");
+
+ const size_t BUFFER_SIZE = 32 * 1024;
+ static_assert(0 == BUFFER_SIZE % TEMPLATE_SIZE, "must be divisible");
+
+ const size_t CHUNK_SIZE_TO_READ = 512;
+ static_assert(0 == CHUNK_SIZE_TO_READ % TEMPLATE_SIZE, "must be divisible");
+
+ // filling buffer
+ // TEMPLATE|TEMPLATE|TEMPLATE|...
+ auto&& buffer = TBuffer{BUFFER_SIZE};
+ for (size_t i = 0; i < BUFFER_SIZE / TEMPLATE_SIZE; ++i) {
+ buffer.Append(TEMPLATE, TEMPLATE_SIZE);
+ }
+
+ // filling file
+ // TEMPLATE|TEMPLATE|TEMPLATE|...
const auto fileName = TString("test.file");
- auto&& directIOBuffer = TDirectIOBufferedFile{fileName, RdWr | CreateAlways | mode};
- {
- auto&& output = TRandomAccessFileOutput{directIOBuffer};
+ auto&& directIOBuffer = TDirectIOBufferedFile{fileName, RdWr | CreateAlways | mode};
+ {
+ auto&& output = TRandomAccessFileOutput{directIOBuffer};
for (size_t i = 0; i < numBufToWrite; ++i) {
- output.Write(buffer.Data(), BUFFER_SIZE);
- }
- }
-
- auto&& reader = TRandomAccessFileInput{directIOBuffer, 0};
- auto&& input = TBufferedInput{&reader, 1 << 17};
- auto bytesRead = size_t{};
- while (auto len = input.Read(buffer.Data(), CHUNK_SIZE_TO_READ)) {
- bytesRead += len;
- while (len) {
- if (len < TEMPLATE_SIZE) {
- UNIT_ASSERT(!memcmp(buffer.Data(), TEMPLATE, len));
- len = 0;
- } else {
- UNIT_ASSERT(!memcmp(buffer.Data(), TEMPLATE, TEMPLATE_SIZE));
- len -= TEMPLATE_SIZE;
- }
- }
- }
-
+ output.Write(buffer.Data(), BUFFER_SIZE);
+ }
+ }
+
+ auto&& reader = TRandomAccessFileInput{directIOBuffer, 0};
+ auto&& input = TBufferedInput{&reader, 1 << 17};
+ auto bytesRead = size_t{};
+ while (auto len = input.Read(buffer.Data(), CHUNK_SIZE_TO_READ)) {
+ bytesRead += len;
+ while (len) {
+ if (len < TEMPLATE_SIZE) {
+ UNIT_ASSERT(!memcmp(buffer.Data(), TEMPLATE, len));
+ len = 0;
+ } else {
+ UNIT_ASSERT(!memcmp(buffer.Data(), TEMPLATE, TEMPLATE_SIZE));
+ len -= TEMPLATE_SIZE;
+ }
+ }
+ }
+
UNIT_ASSERT_VALUES_EQUAL(bytesRead, numBufToWrite * BUFFER_SIZE);
}
- Y_UNIT_TEST(ReadWriteTest) {
+ Y_UNIT_TEST(ReadWriteTest) {
Test(0, 100 * 32);
- }
-
- Y_UNIT_TEST(ReadWriteDirectTest) {
+ }
+
+ Y_UNIT_TEST(ReadWriteDirectTest) {
Test(Direct, 100 * 4);
- }
-
- Y_UNIT_TEST(ReadWriteDirectSeqTest) {
+ }
+
+ Y_UNIT_TEST(ReadWriteDirectSeqTest) {
Test(Direct | Seq, 100 * 4);
}
}
diff --git a/util/stream/file.cpp b/util/stream/file.cpp
index 348a7bfced..dc5d2f6311 100644
--- a/util/stream/file.cpp
+++ b/util/stream/file.cpp
@@ -30,7 +30,7 @@ size_t TUnbufferedFileInput::DoSkip(size_t len) {
* actually doing one read is cheaper. Experiments show that the
* border that separates two implementations performance-wise lies
* in the range of 384-512 bytes (assuming that the file is in OS cache). */
- return IInputStream::DoSkip(len);
+ return IInputStream::DoSkip(len);
}
/* TFile::Seek can seek beyond the end of file, so we need to do
@@ -81,14 +81,14 @@ public:
};
TMappedFileInput::TMappedFileInput(const TFile& file)
- : TMemoryInput(nullptr, 0)
+ : TMemoryInput(nullptr, 0)
, Impl_(new TImpl(file))
{
Reset(Impl_->Data(), Impl_->Size());
}
TMappedFileInput::TMappedFileInput(const TString& path)
- : TMemoryInput(nullptr, 0)
+ : TMemoryInput(nullptr, 0)
, Impl_(new TImpl(TFile(path, OpenExisting | RdOnly)))
{
Reset(Impl_->Data(), Impl_->Size());
diff --git a/util/stream/file.h b/util/stream/file.h
index 1e5217debc..c1cf4f591d 100644
--- a/util/stream/file.h
+++ b/util/stream/file.h
@@ -1,6 +1,6 @@
#pragma once
-#include "fwd.h"
+#include "fwd.h"
#include "input.h"
#include "output.h"
#include "buffered.h"
diff --git a/util/stream/file_ut.cpp b/util/stream/file_ut.cpp
index b39e0d56f5..ac0f09796e 100644
--- a/util/stream/file_ut.cpp
+++ b/util/stream/file_ut.cpp
@@ -8,8 +8,8 @@ static const char* TmpFileName = "./fileio";
static const char* TmpFileContents = "To do good to Mankind is the chivalrous plan";
static const char* TmpFileSubstring = strstr(TmpFileContents, "chivalrous");
-Y_UNIT_TEST_SUITE(TFileTest) {
- Y_UNIT_TEST(InputTest) {
+Y_UNIT_TEST_SUITE(TFileTest) {
+ Y_UNIT_TEST(InputTest) {
TTempFile tmp(TmpFileName);
{
@@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(TFileTest) {
}
}
- Y_UNIT_TEST(EmptyMapTest) {
+ Y_UNIT_TEST(EmptyMapTest) {
TTempFile tmp(TmpFileName);
{
diff --git a/util/stream/format.cpp b/util/stream/format.cpp
index 25f0162552..3996130df5 100644
--- a/util/stream/format.cpp
+++ b/util/stream/format.cpp
@@ -11,7 +11,7 @@ namespace NFormatPrivate {
return (value - res1 < res2 - value) ? (i64)res1 : (i64)res2;
}
- static inline IOutputStream& PrintDoubleShortly(IOutputStream& os, const double& d) {
+ static inline IOutputStream& PrintDoubleShortly(IOutputStream& os, const double& d) {
// General case: request 3 significant digits
// Side-effect: allows exponential representation
EFloatToStringMode mode = PREC_NDIGITS;
@@ -37,7 +37,7 @@ namespace NFormatPrivate {
}
template <>
-void Out<NFormatPrivate::THumanReadableSize>(IOutputStream& stream, const NFormatPrivate::THumanReadableSize& value) {
+void Out<NFormatPrivate::THumanReadableSize>(IOutputStream& stream, const NFormatPrivate::THumanReadableSize& value) {
ui64 base = value.Format == SF_BYTES ? 1024 : 1000;
ui64 base2 = base * base;
ui64 base3 = base * base2;
@@ -71,7 +71,7 @@ void Out<NFormatPrivate::THumanReadableSize>(IOutputStream& stream, const NForma
}
template <>
-void Out<NFormatPrivate::THumanReadableDuration>(IOutputStream& os, const NFormatPrivate::THumanReadableDuration& hr) {
+void Out<NFormatPrivate::THumanReadableDuration>(IOutputStream& os, const NFormatPrivate::THumanReadableDuration& hr) {
TTempBuf buf;
TMemoryOutput ss(buf.Data(), buf.Size());
@@ -107,7 +107,7 @@ void Out<NFormatPrivate::THumanReadableDuration>(IOutputStream& os, const NForma
char names[] = {'d', 'h', 'm', 's'};
bool first = true;
- for (size_t i = 0; i < Y_ARRAY_SIZE(times); ++i) {
+ for (size_t i = 0; i < Y_ARRAY_SIZE(times); ++i) {
if (times[i] > 0) {
if (!first) {
ss << ' ';
@@ -122,13 +122,13 @@ void Out<NFormatPrivate::THumanReadableDuration>(IOutputStream& os, const NForma
os.Write(buf.Data(), written);
}
-void Time(IOutputStream& l) {
+void Time(IOutputStream& l) {
l << millisec();
}
-void TimeHumanReadable(IOutputStream& l) {
+void TimeHumanReadable(IOutputStream& l) {
char timeStr[30];
- const time_t t = time(nullptr);
+ const time_t t = time(nullptr);
l << ctime_r(&t, timeStr);
}
diff --git a/util/stream/format.h b/util/stream/format.h
index 98e5964f7e..b033208a1b 100644
--- a/util/stream/format.h
+++ b/util/stream/format.h
@@ -22,13 +22,13 @@ enum ESizeFormat {
};
namespace NFormatPrivate {
- template <size_t Value>
+ template <size_t Value>
struct TLog2: std::integral_constant<size_t, TLog2<Value / 2>::value + 1> {};
- template <>
+ template <>
struct TLog2<1>: std::integral_constant<size_t, 0> {};
- static inline void WriteChars(IOutputStream& os, char c, size_t count) {
+ static inline void WriteChars(IOutputStream& os, char c, size_t count) {
if (count == 0)
return;
TTempBuf buf(count);
@@ -51,7 +51,7 @@ namespace NFormatPrivate {
};
template <typename T>
- IOutputStream& operator<<(IOutputStream& o, const TLeftPad<T>& lp) {
+ IOutputStream& operator<<(IOutputStream& o, const TLeftPad<T>& lp) {
TTempBuf buf;
TMemoryOutput ss(buf.Data(), buf.Size());
ss << lp.Value;
@@ -78,7 +78,7 @@ namespace NFormatPrivate {
};
template <typename T>
- IOutputStream& operator<<(IOutputStream& o, const TRightPad<T>& lp) {
+ IOutputStream& operator<<(IOutputStream& o, const TRightPad<T>& lp) {
TTempBuf buf;
TMemoryOutput ss(buf.Data(), buf.Size());
ss << lp.Value;
@@ -107,7 +107,7 @@ namespace NFormatPrivate {
using TUnsignedBaseNumber = TBaseNumber<std::make_unsigned_t<std::remove_cv_t<T>>, Base>;
template <typename T, size_t Base>
- IOutputStream& operator<<(IOutputStream& stream, const TBaseNumber<T, Base>& value) {
+ IOutputStream& operator<<(IOutputStream& stream, const TBaseNumber<T, Base>& value) {
char buf[8 * sizeof(T) + 1]; /* Add 1 for sign. */
TStringBuf str(buf, IntToString<Base>(value.Value, buf, sizeof(buf)));
@@ -143,7 +143,7 @@ namespace NFormatPrivate {
};
template <typename Char, size_t Base>
- IOutputStream& operator<<(IOutputStream& os, const TBaseText<Char, Base>& text) {
+ IOutputStream& operator<<(IOutputStream& os, const TBaseText<Char, Base>& text) {
for (size_t i = 0; i < text.Text.size(); ++i) {
if (i != 0) {
os << ' ';
@@ -164,7 +164,7 @@ namespace NFormatPrivate {
};
template <typename T>
- IOutputStream& operator<<(IOutputStream& o, const TFloatPrecision<T>& prec) {
+ IOutputStream& operator<<(IOutputStream& o, const TFloatPrecision<T>& prec) {
char buf[512];
size_t count = FloatToString(prec.Value, buf, sizeof(buf), prec.Mode, prec.NDigits);
o << TStringBuf(buf, count);
@@ -174,7 +174,7 @@ namespace NFormatPrivate {
struct THumanReadableDuration {
TDuration Value;
- constexpr THumanReadableDuration(const TDuration& value)
+ constexpr THumanReadableDuration(const TDuration& value)
: Value(value)
{
}
@@ -190,7 +190,7 @@ namespace NFormatPrivate {
* Output manipulator basically equivalent to `std::setw` and `std::setfill`
* combined.
*
- * When written into a `IOutputStream`, writes out padding characters first,
+ * When written into a `IOutputStream`, writes out padding characters first,
* and then provided value.
*
* Example usage:
@@ -204,7 +204,7 @@ namespace NFormatPrivate {
* @see RightPad
*/
template <typename T>
-static constexpr ::NFormatPrivate::TLeftPad<T> LeftPad(const T& value, const size_t width, const char padc = ' ') noexcept {
+static constexpr ::NFormatPrivate::TLeftPad<T> LeftPad(const T& value, const size_t width, const char padc = ' ') noexcept {
return ::NFormatPrivate::TLeftPad<T>(value, width, padc);
}
@@ -216,7 +216,7 @@ static constexpr ::NFormatPrivate::TLeftPad<const T*> LeftPad(const T (&value)[N
/**
* Output manipulator similar to `std::setw` and `std::setfill`.
*
- * When written into a `IOutputStream`, writes provided value first, and then
+ * When written into a `IOutputStream`, writes provided value first, and then
* the padding characters.
*
* Example usage:
@@ -230,7 +230,7 @@ static constexpr ::NFormatPrivate::TLeftPad<const T*> LeftPad(const T (&value)[N
* @see LeftPad
*/
template <typename T>
-static constexpr ::NFormatPrivate::TRightPad<T> RightPad(const T& value, const size_t width, const char padc = ' ') noexcept {
+static constexpr ::NFormatPrivate::TRightPad<T> RightPad(const T& value, const size_t width, const char padc = ' ') noexcept {
return ::NFormatPrivate::TRightPad<T>(value, width, padc);
}
@@ -242,7 +242,7 @@ static constexpr ::NFormatPrivate::TRightPad<const T*> RightPad(const T (&value)
/**
* Output manipulator similar to `std::setbase(16)`.
*
- * When written into a `IOutputStream`, writes out the provided value in
+ * When written into a `IOutputStream`, writes out the provided value in
* hexadecimal form. The value is treated as unsigned, even if its type is in
* fact signed.
*
@@ -263,7 +263,7 @@ static constexpr ::NFormatPrivate::TUnsignedBaseNumber<T, 16> Hex(const T& value
/**
* Output manipulator similar to `std::setbase(16)`.
*
- * When written into a `IOutputStream`, writes out the provided value in
+ * When written into a `IOutputStream`, writes out the provided value in
* hexadecimal form.
*
* Example usage:
@@ -283,7 +283,7 @@ static constexpr ::NFormatPrivate::TBaseNumber<T, 16> SHex(const T& value, const
/**
* Output manipulator similar to `std::setbase(2)`.
*
- * When written into a `IOutputStream`, writes out the provided value in
+ * When written into a `IOutputStream`, writes out the provided value in
* binary form. The value is treated as unsigned, even if its type is in
* fact signed.
*
@@ -304,7 +304,7 @@ static constexpr ::NFormatPrivate::TUnsignedBaseNumber<T, 2> Bin(const T& value,
/**
* Output manipulator similar to `std::setbase(2)`.
*
- * When written into a `IOutputStream`, writes out the provided value in
+ * When written into a `IOutputStream`, writes out the provided value in
* binary form.
*
* Example usage:
@@ -324,7 +324,7 @@ static constexpr ::NFormatPrivate::TBaseNumber<T, 2> SBin(const T& value, const
/**
* Output manipulator for hexadecimal string output.
*
- * When written into a `IOutputStream`, writes out the provided characters
+ * When written into a `IOutputStream`, writes out the provided characters
* in hexadecimal form divided by space character.
*
* Example usage:
@@ -343,7 +343,7 @@ static inline ::NFormatPrivate::TBaseText<TChar, 16> HexText(const TBasicStringB
/**
* Output manipulator for binary string output.
*
- * When written into a `IOutputStream`, writes out the provided characters
+ * When written into a `IOutputStream`, writes out the provided characters
* in binary form divided by space character.
*
* Example usage:
@@ -361,7 +361,7 @@ static inline ::NFormatPrivate::TBaseText<TChar, 2> BinText(const TBasicStringBu
/**
* Output manipulator for printing `TDuration` values.
*
- * When written into a `IOutputStream`, writes out the provided `TDuration`
+ * When written into a `IOutputStream`, writes out the provided `TDuration`
* in auto-adjusted human-readable format.
*
* Example usage:
@@ -372,7 +372,7 @@ static inline ::NFormatPrivate::TBaseText<TChar, 2> BinText(const TBasicStringBu
*
* @param value Value to output.
*/
-static constexpr ::NFormatPrivate::THumanReadableDuration HumanReadable(const TDuration duration) noexcept {
+static constexpr ::NFormatPrivate::THumanReadableDuration HumanReadable(const TDuration duration) noexcept {
return ::NFormatPrivate::THumanReadableDuration(duration);
}
@@ -380,7 +380,7 @@ static constexpr ::NFormatPrivate::THumanReadableDuration HumanReadable(const TD
* Output manipulator for writing out human-readable number of elements / memory
* amount in `ls -h` style.
*
- * When written into a `IOutputStream`, writes out the provided unsigned integer
+ * When written into a `IOutputStream`, writes out the provided unsigned integer
* variable with small precision and a suffix (like 'K', 'M', 'G' for numbers, or
* 'B', 'KiB', 'MiB', 'GiB' for bytes).
*
@@ -400,13 +400,13 @@ static constexpr ::NFormatPrivate::THumanReadableSize HumanReadableSize(const do
return {size, format};
}
-void Time(IOutputStream& l);
-void TimeHumanReadable(IOutputStream& l);
+void Time(IOutputStream& l);
+void TimeHumanReadable(IOutputStream& l);
/**
* Output manipulator for adjusting precision of floating point values.
*
- * When written into a `IOutputStream`, writes out the provided floating point
+ * When written into a `IOutputStream`, writes out the provided floating point
* variable with given precision. The behavior depends on provided `mode`.
*
* Example usage:
@@ -420,14 +420,14 @@ void TimeHumanReadable(IOutputStream& l);
* @see EFloatToStringMode
*/
template <typename T>
-static constexpr ::NFormatPrivate::TFloatPrecision<T> Prec(const T& value, const EFloatToStringMode mode, const int ndigits = 0) noexcept {
+static constexpr ::NFormatPrivate::TFloatPrecision<T> Prec(const T& value, const EFloatToStringMode mode, const int ndigits = 0) noexcept {
return {value, mode, ndigits};
}
/**
* Output manipulator for adjusting precision of floating point values.
*
- * When written into a `IOutputStream`, writes out the provided floating point
+ * When written into a `IOutputStream`, writes out the provided floating point
* variable with given precision. The behavior is equivalent to `Prec(value, PREC_NDIGITS, ndigits)`.
*
* Example usage:
@@ -439,6 +439,6 @@ static constexpr ::NFormatPrivate::TFloatPrecision<T> Prec(const T& value, const
* @param ndigits Number of significant digits.
*/
template <typename T>
-static constexpr ::NFormatPrivate::TFloatPrecision<T> Prec(const T& value, const int ndigits) noexcept {
+static constexpr ::NFormatPrivate::TFloatPrecision<T> Prec(const T& value, const int ndigits) noexcept {
return {value, PREC_NDIGITS, ndigits};
}
diff --git a/util/stream/format_ut.cpp b/util/stream/format_ut.cpp
index a51d8307f9..43245aeb48 100644
--- a/util/stream/format_ut.cpp
+++ b/util/stream/format_ut.cpp
@@ -3,8 +3,8 @@
#include <library/cpp/testing/unittest/registar.h>
#include <util/charset/wide.h>
-Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
- Y_UNIT_TEST(TestLeftPad) {
+Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
+ Y_UNIT_TEST(TestLeftPad) {
TStringStream ss;
ss << LeftPad(10, 4, '0');
UNIT_ASSERT_VALUES_EQUAL("0010", ss.Str());
@@ -14,7 +14,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
UNIT_ASSERT_VALUES_EQUAL("222", ss.Str());
}
- Y_UNIT_TEST(TestRightPad) {
+ Y_UNIT_TEST(TestRightPad) {
TStringStream ss;
ss << RightPad("aa", 4);
UNIT_ASSERT_VALUES_EQUAL("aa ", ss.Str());
@@ -24,14 +24,14 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
UNIT_ASSERT_VALUES_EQUAL("aa", ss.Str());
}
- Y_UNIT_TEST(TestTime) {
+ Y_UNIT_TEST(TestTime) {
TStringStream ss;
ss << "[" << Time << "] "
<< "qwqw" << TimeHumanReadable << Endl;
}
- Y_UNIT_TEST(TestHexReference) {
+ Y_UNIT_TEST(TestHexReference) {
/*
One possible implementation of Hex() stores a reference to the given object.
This can lead to wrong results if the given object is a temporary
@@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
UNIT_ASSERT_VALUES_EQUAL("0x01234567", ss->Str());
}
- Y_UNIT_TEST(TestHexText) {
+ Y_UNIT_TEST(TestHexText) {
{
TStringStream ss;
ss << HexText(TStringBuf("abcи"));
@@ -60,13 +60,13 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
}
}
- Y_UNIT_TEST(TestBin) {
+ Y_UNIT_TEST(TestBin) {
UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<ui32>(2), nullptr)), "10");
UNIT_ASSERT_VALUES_EQUAL(ToString(SBin(static_cast<i32>(-2), nullptr)), "-10");
UNIT_ASSERT_VALUES_EQUAL(ToString(SBin(static_cast<i32>(-2))), "-0b00000000000000000000000000000010");
UNIT_ASSERT_VALUES_EQUAL(ToString(SBin(static_cast<i32>(-2), HF_FULL)), "-00000000000000000000000000000010");
UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<ui32>(15), nullptr)), "1111");
- UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<ui32>(1))), "0b00000000000000000000000000000001");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<ui32>(1))), "0b00000000000000000000000000000001");
UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<ui32>(-1))), "0b11111111111111111111111111111111");
UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<i32>(-1))), "0b11111111111111111111111111111111");
UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<i32>(-1), nullptr)), "11111111111111111111111111111111");
@@ -75,13 +75,13 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<ui64>(1234587912357ull))), "0b0000000000000000000000010001111101110011001011001000100010100101");
}
- Y_UNIT_TEST(TestBinText) {
+ Y_UNIT_TEST(TestBinText) {
UNIT_ASSERT_VALUES_EQUAL(ToString(BinText(TStringBuf("\1"))), "00000001");
UNIT_ASSERT_VALUES_EQUAL(ToString(BinText(TStringBuf("\1\1"))), "00000001 00000001");
UNIT_ASSERT_VALUES_EQUAL(ToString(BinText(TStringBuf("aaa"))), "01100001 01100001 01100001");
}
- Y_UNIT_TEST(TestPrec) {
+ Y_UNIT_TEST(TestPrec) {
TStringStream ss;
ss << Prec(1.2345678901234567, PREC_AUTO);
UNIT_ASSERT_VALUES_EQUAL("1.2345678901234567", ss.Str());
@@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
UNIT_ASSERT_VALUES_EQUAL("1.235", ss.Str());
}
- Y_UNIT_TEST(TestHumanReadableSize1000) {
+ Y_UNIT_TEST(TestHumanReadableSize1000) {
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(0, SF_QUANTITY)), "0");
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(1, SF_QUANTITY)), "1");
@@ -111,7 +111,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-12345678 * 1000ll, SF_QUANTITY)), "-12.3G");
}
- Y_UNIT_TEST(TestHumanReadableSize1024) {
+ Y_UNIT_TEST(TestHumanReadableSize1024) {
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(0, SF_BYTES)), "0B");
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(100, SF_BYTES)), "100B");
@@ -161,7 +161,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-1010ll * 1024 * 1024 * 1024 * 1024, SF_BYTES)), "-1010TiB");
}
- Y_UNIT_TEST(TestHumanReadableDuration) {
+ Y_UNIT_TEST(TestHumanReadableDuration) {
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(0))), "0us");
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(1))), "1us");
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(100))), "100us");
diff --git a/util/stream/fwd.cpp b/util/stream/fwd.cpp
index 2261ef316c..4214b6df83 100644
--- a/util/stream/fwd.cpp
+++ b/util/stream/fwd.cpp
@@ -1 +1 @@
-#include "fwd.h"
+#include "fwd.h"
diff --git a/util/stream/fwd.h b/util/stream/fwd.h
index 3f0b89299b..307676c6a7 100644
--- a/util/stream/fwd.h
+++ b/util/stream/fwd.h
@@ -1,100 +1,100 @@
-#pragma once
-
-#include <util/system/types.h>
-
-class IInputStream;
-class IOutputStream;
-
-class IZeroCopyInput;
-class IZeroCopyInputFastReadTo;
+#pragma once
+
+#include <util/system/types.h>
+
+class IInputStream;
+class IOutputStream;
+
+class IZeroCopyInput;
+class IZeroCopyInputFastReadTo;
class IZeroCopyOutput;
-
-using TStreamManipulator = void (*)(IOutputStream&);
-
-class TLengthLimitedInput;
-class TCountingInput;
-class TCountingOutput;
-
-class TMemoryInput;
-class TMemoryOutput;
-class TMemoryWriteBuffer;
-
-class TMultiInput;
-
-class TNullInput;
-class TNullOutput;
-class TNullIO;
-
-class TPipeBase;
-class TPipeInput;
-class TPipeOutput;
-class TPipedBase;
-class TPipedInput;
-class TPipedOutput;
-
-class TStringInput;
-class TStringOutput;
-class TStringStream;
-
-class TTeeOutput;
-
+
+using TStreamManipulator = void (*)(IOutputStream&);
+
+class TLengthLimitedInput;
+class TCountingInput;
+class TCountingOutput;
+
+class TMemoryInput;
+class TMemoryOutput;
+class TMemoryWriteBuffer;
+
+class TMultiInput;
+
+class TNullInput;
+class TNullOutput;
+class TNullIO;
+
+class TPipeBase;
+class TPipeInput;
+class TPipeOutput;
+class TPipedBase;
+class TPipedInput;
+class TPipedOutput;
+
+class TStringInput;
+class TStringOutput;
+class TStringStream;
+
+class TTeeOutput;
+
class TTempBufOutput;
-
-struct TEol;
-
-template <typename TEndOfToken>
-class TStreamTokenizer;
-
+
+struct TEol;
+
+template <typename TEndOfToken>
+class TStreamTokenizer;
+
enum ETraceLevel: ui8;
-
-class IWalkInput;
-
-struct TZLibError;
-struct TZLibCompressorError;
-struct TZLibDecompressorError;
-
-namespace ZLib {
+
+class IWalkInput;
+
+struct TZLibError;
+struct TZLibCompressorError;
+struct TZLibDecompressorError;
+
+namespace ZLib {
enum StreamType: ui8;
-}
-
+}
+
class TZLibDecompress;
-class TZLibCompress;
-class TBufferedZLibDecompress;
-
-using TZDecompress = TBufferedZLibDecompress;
-
-class TAlignedInput;
-class TAlignedOutput;
-
-class TBufferInput;
-class TBufferOutput;
-class TBufferStream;
-
-class TBufferedInput;
-class TBufferedOutputBase;
-class TBufferedOutput;
-class TAdaptiveBufferedOutput;
-
-template <class TSlave>
-class TBuffered;
-
-template <class TSlave>
-class TAdaptivelyBuffered;
-
-class TDebugOutput;
-
-class TRandomAccessFileInput;
-class TRandomAccessFileOutput;
-class TBufferedFileOutputEx;
-
-class TUnbufferedFileInput;
-class TMappedFileInput;
-class TUnbufferedFileOutput;
-
-class TFileInput;
-using TIFStream = TFileInput;
-
-class TFixedBufferFileOutput;
-using TOFStream = TFixedBufferFileOutput;
-
-using TFileOutput = TAdaptivelyBuffered<TUnbufferedFileOutput>;
+class TZLibCompress;
+class TBufferedZLibDecompress;
+
+using TZDecompress = TBufferedZLibDecompress;
+
+class TAlignedInput;
+class TAlignedOutput;
+
+class TBufferInput;
+class TBufferOutput;
+class TBufferStream;
+
+class TBufferedInput;
+class TBufferedOutputBase;
+class TBufferedOutput;
+class TAdaptiveBufferedOutput;
+
+template <class TSlave>
+class TBuffered;
+
+template <class TSlave>
+class TAdaptivelyBuffered;
+
+class TDebugOutput;
+
+class TRandomAccessFileInput;
+class TRandomAccessFileOutput;
+class TBufferedFileOutputEx;
+
+class TUnbufferedFileInput;
+class TMappedFileInput;
+class TUnbufferedFileOutput;
+
+class TFileInput;
+using TIFStream = TFileInput;
+
+class TFixedBufferFileOutput;
+using TOFStream = TFixedBufferFileOutput;
+
+using TFileOutput = TAdaptivelyBuffered<TUnbufferedFileOutput>;
diff --git a/util/stream/hex.cpp b/util/stream/hex.cpp
index 639a7d9370..1c05330504 100644
--- a/util/stream/hex.cpp
+++ b/util/stream/hex.cpp
@@ -3,7 +3,7 @@
#include "output.h"
#include <util/string/hex.h>
-void HexEncode(const void* in, size_t len, IOutputStream& out) {
+void HexEncode(const void* in, size_t len, IOutputStream& out) {
static const size_t NUM_OF_BYTES = 32;
char buffer[NUM_OF_BYTES * 2];
@@ -15,7 +15,7 @@ void HexEncode(const void* in, size_t len, IOutputStream& out) {
}
}
-void HexDecode(const void* in, size_t len, IOutputStream& out) {
+void HexDecode(const void* in, size_t len, IOutputStream& out) {
Y_ENSURE(!(len & 1), TStringBuf("Odd buffer length passed to HexDecode"));
static const size_t NUM_OF_BYTES = 32;
diff --git a/util/stream/hex.h b/util/stream/hex.h
index abe13e30ca..a018933b1b 100644
--- a/util/stream/hex.h
+++ b/util/stream/hex.h
@@ -2,7 +2,7 @@
#include <util/system/types.h>
-class IOutputStream;
+class IOutputStream;
-void HexEncode(const void* in, size_t len, IOutputStream& out);
-void HexDecode(const void* in, size_t len, IOutputStream& out);
+void HexEncode(const void* in, size_t len, IOutputStream& out);
+void HexDecode(const void* in, size_t len, IOutputStream& out);
diff --git a/util/stream/hex_ut.cpp b/util/stream/hex_ut.cpp
index 81c26b27c2..5074a0b616 100644
--- a/util/stream/hex_ut.cpp
+++ b/util/stream/hex_ut.cpp
@@ -3,7 +3,7 @@
#include <library/cpp/testing/unittest/registar.h>
#include "str.h"
-Y_UNIT_TEST_SUITE(THexCodingTest) {
+Y_UNIT_TEST_SUITE(THexCodingTest) {
void TestImpl(const TString& data) {
TString encoded;
TStringOutput encodedOut(encoded);
@@ -18,12 +18,12 @@ Y_UNIT_TEST_SUITE(THexCodingTest) {
UNIT_ASSERT_EQUAL(decoded, data);
}
- Y_UNIT_TEST(TestEncodeDecodeToStream) {
+ Y_UNIT_TEST(TestEncodeDecodeToStream) {
TString data = "100ABAcaba500,$%0987123456 \n\t\x01\x02\x03.";
TestImpl(data);
}
- Y_UNIT_TEST(TestEmpty) {
+ Y_UNIT_TEST(TestEmpty) {
TestImpl("");
}
}
diff --git a/util/stream/holder.h b/util/stream/holder.h
index fabbc860b1..c60a4e510c 100644
--- a/util/stream/holder.h
+++ b/util/stream/holder.h
@@ -5,18 +5,18 @@
#include <utility>
#include <type_traits>
-class IInputStream;
-class IOutputStream;
+class IInputStream;
+class IOutputStream;
namespace NPrivate {
- template <class Stream, bool isInput = std::is_base_of<IInputStream, Stream>::value>
+ template <class Stream, bool isInput = std::is_base_of<IInputStream, Stream>::value>
struct TStreamBase {
- using TType = IInputStream;
+ using TType = IInputStream;
};
template <class Stream>
struct TStreamBase<Stream, false> {
- using TType = IOutputStream;
+ using TType = IOutputStream;
};
}
diff --git a/util/stream/input.cpp b/util/stream/input.cpp
index a365b9c0d0..6e8170f2f9 100644
--- a/util/stream/input.cpp
+++ b/util/stream/input.cpp
@@ -13,11 +13,11 @@
#include <cstdlib>
-IInputStream::IInputStream() noexcept = default;
+IInputStream::IInputStream() noexcept = default;
-IInputStream::~IInputStream() = default;
+IInputStream::~IInputStream() = default;
-size_t IInputStream::DoReadTo(TString& st, char to) {
+size_t IInputStream::DoReadTo(TString& st, char to) {
char ch;
if (!Read(&ch, 1)) {
@@ -40,7 +40,7 @@ size_t IInputStream::DoReadTo(TString& st, char to) {
return result;
}
-ui64 IInputStream::DoReadAll(IOutputStream& out) {
+ui64 IInputStream::DoReadAll(IOutputStream& out) {
TTempBuf buffer;
void* ptr = buffer.Data();
size_t size = buffer.Size();
@@ -54,7 +54,7 @@ ui64 IInputStream::DoReadAll(IOutputStream& out) {
return result;
}
-size_t IInputStream::Load(void* buf_in, size_t len) {
+size_t IInputStream::Load(void* buf_in, size_t len) {
char* buf = (char*)buf_in;
while (len) {
@@ -71,14 +71,14 @@ size_t IInputStream::Load(void* buf_in, size_t len) {
return buf - (char*)buf_in;
}
-void IInputStream::LoadOrFail(void* buf, size_t len) {
+void IInputStream::LoadOrFail(void* buf, size_t len) {
const size_t realLen = Load(buf, len);
- if (Y_UNLIKELY(realLen != len)) {
+ if (Y_UNLIKELY(realLen != len)) {
ythrow yexception() << "Failed to read required number of bytes from stream! Expected: " << len << ", gained: " << realLen << "!";
}
}
-size_t IInputStream::ReadLine(TString& st) {
+size_t IInputStream::ReadLine(TString& st) {
const size_t ret = ReadTo(st, '\n');
if (ret && !st.empty() && st.back() == '\r') {
@@ -88,7 +88,7 @@ size_t IInputStream::ReadLine(TString& st) {
return ret;
}
-size_t IInputStream::ReadLine(TUtf16String& w) {
+size_t IInputStream::ReadLine(TUtf16String& w) {
TString s;
size_t result = ReadLine(s);
@@ -99,7 +99,7 @@ size_t IInputStream::ReadLine(TUtf16String& w) {
return result;
}
-TString IInputStream::ReadLine() {
+TString IInputStream::ReadLine() {
TString ret;
if (!ReadLine(ret)) {
@@ -109,7 +109,7 @@ TString IInputStream::ReadLine() {
return ret;
}
-TString IInputStream::ReadTo(char ch) {
+TString IInputStream::ReadTo(char ch) {
TString ret;
if (!ReadTo(ret, ch)) {
@@ -119,11 +119,11 @@ TString IInputStream::ReadTo(char ch) {
return ret;
}
-size_t IInputStream::Skip(size_t sz) {
+size_t IInputStream::Skip(size_t sz) {
return DoSkip(sz);
}
-size_t IInputStream::DoSkip(size_t sz) {
+size_t IInputStream::DoSkip(size_t sz) {
if (sz < 128) {
return Load(alloca(sz), sz);
}
@@ -145,7 +145,7 @@ size_t IInputStream::DoSkip(size_t sz) {
return total;
}
-TString IInputStream::ReadAll() {
+TString IInputStream::ReadAll() {
TString result;
TStringOutput stream(result);
@@ -154,16 +154,16 @@ TString IInputStream::ReadAll() {
return result;
}
-ui64 IInputStream::ReadAll(IOutputStream& out) {
+ui64 IInputStream::ReadAll(IOutputStream& out) {
return DoReadAll(out);
}
-ui64 TransferData(IInputStream* in, IOutputStream* out) {
+ui64 TransferData(IInputStream* in, IOutputStream* out) {
return in->ReadAll(*out);
}
namespace {
- struct TStdIn: public IInputStream {
+ struct TStdIn: public IInputStream {
~TStdIn() override = default;
size_t DoRead(void* buf, size_t len) override {
@@ -250,7 +250,7 @@ namespace {
#endif
}
-IInputStream& NPrivate::StdInStream() noexcept {
+IInputStream& NPrivate::StdInStream() noexcept {
return *SingletonWithPriority<TGetLine, 4>();
}
@@ -262,7 +262,7 @@ static inline bool IsStdDelimiter(char c) {
return (c == '\0') || (c == ' ') || (c == '\r') || (c == '\n') || (c == '\t');
}
-static void ReadUpToDelimiter(IInputStream& i, TString& s) {
+static void ReadUpToDelimiter(IInputStream& i, TString& s) {
char c;
while (i.ReadChar(c)) { // skip delimiters
if (!IsStdDelimiter(c)) {
@@ -278,13 +278,13 @@ static void ReadUpToDelimiter(IInputStream& i, TString& s) {
// specialization for string-related stuff
template <>
-void In<TString>(IInputStream& i, TString& s) {
+void In<TString>(IInputStream& i, TString& s) {
s.resize(0);
ReadUpToDelimiter(i, s);
}
template <>
-void In<TUtf16String>(IInputStream& i, TUtf16String& w) {
+void In<TUtf16String>(IInputStream& i, TUtf16String& w) {
TString s;
ReadUpToDelimiter(i, s);
@@ -299,7 +299,7 @@ void In<TUtf16String>(IInputStream& i, TUtf16String& w) {
#define SPEC_FOR_CHAR(T) \
template <> \
- void In<T>(IInputStream & i, T & t) { \
+ void In<T>(IInputStream & i, T & t) { \
i.ReadChar((char&)t); \
}
@@ -313,7 +313,7 @@ SPEC_FOR_CHAR(signed char)
#define SPEC_FOR_NUMBER(T) \
template <> \
- void In<T>(IInputStream & i, T & t) { \
+ void In<T>(IInputStream & i, T & t) { \
char buf[128]; \
size_t pos = 0; \
while (i.ReadChar(buf[0])) { \
diff --git a/util/stream/input.h b/util/stream/input.h
index 4858660457..f0d5807ed2 100644
--- a/util/stream/input.h
+++ b/util/stream/input.h
@@ -4,7 +4,7 @@
#include <util/generic/noncopyable.h>
#include <util/system/defaults.h>
-class IOutputStream;
+class IOutputStream;
/**
* @addtogroup Streams_Base
@@ -14,15 +14,15 @@ class IOutputStream;
/**
* Abstract input stream.
*/
-class IInputStream: public TNonCopyable {
+class IInputStream: public TNonCopyable {
public:
- IInputStream() noexcept;
- virtual ~IInputStream();
+ IInputStream() noexcept;
+ virtual ~IInputStream();
- IInputStream(IInputStream&&) noexcept {
+ IInputStream(IInputStream&&) noexcept {
}
- IInputStream& operator=(IInputStream&&) noexcept {
+ IInputStream& operator=(IInputStream&&) noexcept {
return *this;
}
@@ -107,7 +107,7 @@ public:
* @param out Output stream to use.
* @returns Total number of characters read from the stream.
*/
- ui64 ReadAll(IOutputStream& out);
+ ui64 ReadAll(IOutputStream& out);
/**
* Reads all data from the stream until the first occurrence of '\n'. Also
@@ -215,7 +215,7 @@ protected:
* this stream.
* @throws yexception If IO error occurs.
*/
- virtual ui64 DoReadAll(IOutputStream& out);
+ virtual ui64 DoReadAll(IOutputStream& out);
};
/**
@@ -224,10 +224,10 @@ protected:
* @param in Input stream.
* @param out Output stream.
*/
-ui64 TransferData(IInputStream* in, IOutputStream* out);
+ui64 TransferData(IInputStream* in, IOutputStream* out);
/**
- * `operator>>` for `IInputStream` by default delegates to this function.
+ * `operator>>` for `IInputStream` by default delegates to this function.
*
* Note that while `operator>>` uses overloading (and thus argument-dependent
* lookup), `In` uses template specializations. This makes it possible to
@@ -241,10 +241,10 @@ ui64 TransferData(IInputStream* in, IOutputStream* out);
* @param in Input stream to read from.
* @param[out] value Value to read.
* @throws `yexception` on invalid input or end of stream.
- * @see Out(IOutputStream&, T&)
+ * @see Out(IOutputStream&, T&)
*/
template <typename T>
-void In(IInputStream& in, T& value);
+void In(IInputStream& in, T& value);
/**
* Reads a value from the stream.
@@ -253,16 +253,16 @@ void In(IInputStream& in, T& value);
* @param[out] value Value to read.
* @returns Input stream.
* @throws `yexception` on invalid input or end of stream.
- * @see operator<<(IOutputStream&, T&)
+ * @see operator<<(IOutputStream&, T&)
*/
template <typename T>
-inline IInputStream& operator>>(IInputStream& in, T& value) {
+inline IInputStream& operator>>(IInputStream& in, T& value) {
In<T>(in, value);
return in;
}
namespace NPrivate {
- IInputStream& StdInStream() noexcept;
+ IInputStream& StdInStream() noexcept;
}
/**
diff --git a/util/stream/input_ut.cpp b/util/stream/input_ut.cpp
index 63e2d08c88..4a93f5458e 100644
--- a/util/stream/input_ut.cpp
+++ b/util/stream/input_ut.cpp
@@ -21,7 +21,7 @@ public:
}
template <typename FuncType>
- void ForInput(const TStringBuf text, const FuncType& func) {
+ void ForInput(const TStringBuf text, const FuncType& func) {
TFile tempFile(TFile::Temporary("input_ut"));
tempFile.Write(text.data(), text.size());
tempFile.FlushData();
@@ -41,7 +41,7 @@ private:
int StdInCopy_;
};
-class TNoInput: public IInputStream {
+class TNoInput: public IInputStream {
public:
TNoInput(ui64 size)
: Size_(size)
@@ -59,7 +59,7 @@ private:
ui64 Size_;
};
-class TNoOutput: public IOutputStream {
+class TNoOutput: public IOutputStream {
public:
TNoOutput() = default;
@@ -68,7 +68,7 @@ protected:
}
};
-class TSimpleStringInput: public IInputStream {
+class TSimpleStringInput: public IInputStream {
public:
TSimpleStringInput(const TString& string)
: String_(string)
@@ -77,7 +77,7 @@ public:
protected:
size_t DoRead(void* buf, size_t len) override {
- Y_ASSERT(len != 0);
+ Y_ASSERT(len != 0);
if (String_.empty()) {
return 0;
@@ -92,8 +92,8 @@ private:
TString String_;
};
-Y_UNIT_TEST_SUITE(TInputTest) {
- Y_UNIT_TEST(BigTransfer) {
+Y_UNIT_TEST_SUITE(TInputTest) {
+ Y_UNIT_TEST(BigTransfer) {
ui64 size = 1024ull * 1024ull * 1024ull * 5;
TNoInput input(size);
TNoOutput output;
@@ -103,7 +103,7 @@ Y_UNIT_TEST_SUITE(TInputTest) {
UNIT_ASSERT_VALUES_EQUAL(transferred, size);
}
- Y_UNIT_TEST(TestReadTo) {
+ Y_UNIT_TEST(TestReadTo) {
/* This one tests default implementation of ReadTo. */
TSimpleStringInput in("0123456789abc");
@@ -117,7 +117,7 @@ Y_UNIT_TEST_SUITE(TInputTest) {
UNIT_ASSERT_VALUES_EQUAL(t, "89abc");
}
- Y_UNIT_TEST(TestReadLine) {
+ Y_UNIT_TEST(TestReadLine) {
TSimpleStringInput in("1\n22\n333");
TString t;
@@ -131,7 +131,7 @@ Y_UNIT_TEST_SUITE(TInputTest) {
UNIT_ASSERT_VALUES_EQUAL(t, "333");
}
- Y_UNIT_TEST(TestStdInReadTo) {
+ Y_UNIT_TEST(TestStdInReadTo) {
std::pair<std::pair<TStringBuf, char>, TStringBuf> testPairs[] = {
{{"", '\n'}, ""},
{{"\n", '\n'}, ""},
diff --git a/util/stream/ios_ut.cpp b/util/stream/ios_ut.cpp
index 30ae17cdf4..139f4296e5 100644
--- a/util/stream/ios_ut.cpp
+++ b/util/stream/ios_ut.cpp
@@ -1,7 +1,7 @@
-#include "output.h"
+#include "output.h"
#include "tokenizer.h"
-#include "buffer.h"
-#include "buffered.h"
+#include "buffer.h"
+#include "buffered.h"
#include "walk.h"
#include <library/cpp/testing/unittest/registar.h>
@@ -169,7 +169,7 @@ void TStreamsTest::TestMemoryStream() {
}
}
-class TMyStringOutput: public IOutputStream {
+class TMyStringOutput: public IOutputStream {
public:
inline TMyStringOutput(TString& s, size_t buflen) noexcept
: S_(s)
@@ -279,7 +279,7 @@ void TStreamsTest::TestBufferStream() {
}
namespace {
- class TStringListInput: public IWalkInput {
+ class TStringListInput: public IWalkInput {
public:
TStringListInput(const TVector<TString>& data)
: Data_(data)
@@ -331,7 +331,7 @@ namespace {
"\rone two",
"123",
"\t\r "};
- void TestStreamReadTo1(IInputStream& input, const char* comment) {
+ void TestStreamReadTo1(IInputStream& input, const char* comment) {
TString tmp;
input.ReadTo(tmp, 'c');
UNIT_ASSERT_VALUES_EQUAL_C(tmp, "111a222b333", comment);
@@ -347,7 +347,7 @@ namespace {
UNIT_ASSERT_VALUES_EQUAL_C(tmp, "66f", comment);
}
- void TestStreamReadTo2(IInputStream& input, const char* comment) {
+ void TestStreamReadTo2(IInputStream& input, const char* comment) {
TString s;
size_t i = 0;
while (input.ReadLine(s)) {
@@ -357,17 +357,17 @@ namespace {
}
}
- void TestStreamReadTo3(IInputStream& input, const char* comment) {
+ void TestStreamReadTo3(IInputStream& input, const char* comment) {
UNIT_ASSERT_VALUES_EQUAL_C(input.ReadLine(), "111a222b333c444d555e666f", comment);
}
- void TestStreamReadTo4(IInputStream& input, const char* comment) {
+ void TestStreamReadTo4(IInputStream& input, const char* comment) {
UNIT_ASSERT_VALUES_EQUAL_C(input.ReadTo('\0'), "one", comment);
UNIT_ASSERT_VALUES_EQUAL_C(input.ReadTo('\0'), "two", comment);
UNIT_ASSERT_VALUES_EQUAL_C(input.ReadTo('\0'), "three", comment);
}
- void TestStrokaInput(IInputStream& input, const char* comment) {
+ void TestStrokaInput(IInputStream& input, const char* comment) {
TString line;
ui32 i = 0;
TInstant start = Now();
@@ -392,7 +392,7 @@ namespace {
test(bdi, "TBufferedInput");
TVector<TString> lst(1, text);
TStringListInput sli(lst);
- test(sli, "IWalkInput");
+ test(sli, "IWalkInput");
}
}
@@ -422,7 +422,7 @@ void TStreamsTest::TestWtrokaInput() {
size_t i = 0;
while (is.ReadLine(w)) {
- UNIT_ASSERT(i < Y_ARRAY_SIZE(Expected));
+ UNIT_ASSERT(i < Y_ARRAY_SIZE(Expected));
UNIT_ASSERT_VALUES_EQUAL(w, UTF8ToWide(Expected[i]));
++i;
diff --git a/util/stream/labeled.h b/util/stream/labeled.h
index cd0017b00f..2cc539d241 100644
--- a/util/stream/labeled.h
+++ b/util/stream/labeled.h
@@ -13,7 +13,7 @@
* // Outputs "a = 1, b = 2, c = 3, a + b + c = 6"
* @endcode
*/
-#define LabeledOutput(...) "" Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__LABELED_OUTPUT_NONLAST__, __LABELED_OUTPUT_IMPL__, __VA_ARGS__))
+#define LabeledOutput(...) "" Y_PASS_VA_ARGS(Y_MAP_ARGS_WITH_LAST(__LABELED_OUTPUT_NONLAST__, __LABELED_OUTPUT_IMPL__, __VA_ARGS__))
#define __LABELED_OUTPUT_IMPL__(x) << #x " = " << (x)
#define __LABELED_OUTPUT_NONLAST__(x) __LABELED_OUTPUT_IMPL__(x) << ", "
diff --git a/util/stream/labeled_ut.cpp b/util/stream/labeled_ut.cpp
index f30fdebe8b..12d0dc5004 100644
--- a/util/stream/labeled_ut.cpp
+++ b/util/stream/labeled_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TLabeledOutputTest) {
- Y_UNIT_TEST(TBasicTest) {
+Y_UNIT_TEST_SUITE(TLabeledOutputTest) {
+ Y_UNIT_TEST(TBasicTest) {
TStringStream out;
int x = 3;
out << LabeledOutput(x, 1, 2, 3 + 4);
diff --git a/util/stream/length.cpp b/util/stream/length.cpp
index 04dfcedb49..9907fe2ac9 100644
--- a/util/stream/length.cpp
+++ b/util/stream/length.cpp
@@ -34,7 +34,7 @@ size_t TCountingInput::DoReadTo(TString& st, char ch) {
return ret;
}
-ui64 TCountingInput::DoReadAll(IOutputStream& out) {
+ui64 TCountingInput::DoReadAll(IOutputStream& out) {
const ui64 ret = Slave_->ReadAll(out);
Count_ += ret;
return ret;
diff --git a/util/stream/length.h b/util/stream/length.h
index 79eb59e2e0..4d508ae24d 100644
--- a/util/stream/length.h
+++ b/util/stream/length.h
@@ -12,9 +12,9 @@
* This can be useful for breaking up the slave stream into small chunks and
* treat these as separate streams.
*/
-class TLengthLimitedInput: public IInputStream {
+class TLengthLimitedInput: public IInputStream {
public:
- inline TLengthLimitedInput(IInputStream* slave, ui64 length) noexcept
+ inline TLengthLimitedInput(IInputStream* slave, ui64 length) noexcept
: Slave_(slave)
, Length_(length)
{
@@ -31,16 +31,16 @@ private:
size_t DoSkip(size_t len) override;
private:
- IInputStream* Slave_;
+ IInputStream* Slave_;
ui64 Length_;
};
/**
* Proxy input stream that counts the number of characters read.
*/
-class TCountingInput: public IInputStream {
+class TCountingInput: public IInputStream {
public:
- inline TCountingInput(IInputStream* slave) noexcept
+ inline TCountingInput(IInputStream* slave) noexcept
: Slave_(slave)
, Count_()
{
@@ -60,19 +60,19 @@ private:
size_t DoRead(void* buf, size_t len) override;
size_t DoSkip(size_t len) override;
size_t DoReadTo(TString& st, char ch) override;
- ui64 DoReadAll(IOutputStream& out) override;
+ ui64 DoReadAll(IOutputStream& out) override;
private:
- IInputStream* Slave_;
+ IInputStream* Slave_;
ui64 Count_;
};
/**
* Proxy output stream that counts the number of characters written.
*/
-class TCountingOutput: public IOutputStream {
+class TCountingOutput: public IOutputStream {
public:
- inline TCountingOutput(IOutputStream* slave) noexcept
+ inline TCountingOutput(IOutputStream* slave) noexcept
: Slave_(slave)
, Count_()
{
@@ -95,6 +95,6 @@ private:
void DoWrite(const void* buf, size_t len) override;
private:
- IOutputStream* Slave_;
+ IOutputStream* Slave_;
ui64 Count_;
};
diff --git a/util/stream/length_ut.cpp b/util/stream/length_ut.cpp
index 9cc4621624..8968448954 100644
--- a/util/stream/length_ut.cpp
+++ b/util/stream/length_ut.cpp
@@ -4,8 +4,8 @@
#include <util/generic/string.h>
-Y_UNIT_TEST_SUITE(TestLengthIO) {
- Y_UNIT_TEST(TestLengthLimitedInput) {
+Y_UNIT_TEST_SUITE(TestLengthIO) {
+ Y_UNIT_TEST(TestLengthLimitedInput) {
char buf[16];
TStringStream s1("abcd");
@@ -14,7 +14,7 @@ Y_UNIT_TEST_SUITE(TestLengthIO) {
UNIT_ASSERT_VALUES_EQUAL(l1.Read(buf, 1), 0);
}
- Y_UNIT_TEST(TestCountingInput) {
+ Y_UNIT_TEST(TestCountingInput) {
char buf[16];
TStringStream s1("abc\ndef\n");
@@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(TestLengthIO) {
UNIT_ASSERT_VALUES_EQUAL(l1.Counter(), 8);
}
- Y_UNIT_TEST(TestCountingOutput) {
+ Y_UNIT_TEST(TestCountingOutput) {
TStringStream s1;
TCountingOutput l1(&s1);
diff --git a/util/stream/mem.cpp b/util/stream/mem.cpp
index c352eb3894..22a3339e27 100644
--- a/util/stream/mem.cpp
+++ b/util/stream/mem.cpp
@@ -14,7 +14,7 @@ TMemoryInput::TMemoryInput(const void* buf, size_t len) noexcept
{
}
-TMemoryInput::TMemoryInput(const TStringBuf buf) noexcept
+TMemoryInput::TMemoryInput(const TStringBuf buf) noexcept
: Buf_(buf.data())
, Len_(buf.size())
{
diff --git a/util/stream/mem.h b/util/stream/mem.h
index bde672528d..18a5d46772 100644
--- a/util/stream/mem.h
+++ b/util/stream/mem.h
@@ -13,7 +13,7 @@
/**
* Input stream that reads data from a memory block.
*/
-class TMemoryInput: public IZeroCopyInputFastReadTo {
+class TMemoryInput: public IZeroCopyInputFastReadTo {
public:
TMemoryInput() noexcept;
@@ -26,11 +26,11 @@ public:
* @param len Size of the memory block.
*/
TMemoryInput(const void* buf, size_t len) noexcept;
- explicit TMemoryInput(const TStringBuf buf) noexcept;
+ explicit TMemoryInput(const TStringBuf buf) noexcept;
~TMemoryInput() override;
TMemoryInput(const TMemoryInput& other) noexcept
- : IZeroCopyInputFastReadTo()
+ : IZeroCopyInputFastReadTo()
, Buf_(other.Buf_)
, Len_(other.Len_)
{
@@ -89,10 +89,10 @@ public:
*
* @param stream Zero copy stream to initialize from.
*/
- void Fill(IZeroCopyInput* stream) {
+ void Fill(IZeroCopyInput* stream) {
Len_ = stream->Next(&Buf_);
if (!Len_) {
- Reset(nullptr, 0);
+ Reset(nullptr, 0);
}
}
@@ -229,7 +229,7 @@ public:
* this stream uses.
*/
void SetPos(char* ptr) {
- Y_ASSERT(Beg_ <= ptr);
+ Y_ASSERT(Beg_ <= ptr);
SetPosImpl(ptr);
}
@@ -244,7 +244,7 @@ public:
protected:
void SetPosImpl(char* ptr) {
- Y_ASSERT(End_ >= ptr);
+ Y_ASSERT(End_ >= ptr);
Buf_ = ptr;
}
diff --git a/util/stream/mem_ut.cpp b/util/stream/mem_ut.cpp
index cd8c047435..f388ae66ac 100644
--- a/util/stream/mem_ut.cpp
+++ b/util/stream/mem_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TestMemIO) {
- Y_UNIT_TEST(TestReadTo) {
+Y_UNIT_TEST_SUITE(TestMemIO) {
+ Y_UNIT_TEST(TestReadTo) {
TString s("0123456789abc");
TMemoryInput in(s);
@@ -50,7 +50,7 @@ Y_UNIT_TEST_SUITE(TestMemIO) {
UNIT_ASSERT(0 == memcmp(buffer, result, strlen(result)));
}
- Y_UNIT_TEST(Write) {
+ Y_UNIT_TEST(Write) {
char buffer[20];
TMemoryOutput output(buffer, sizeof(buffer));
output << "1"
@@ -67,7 +67,7 @@ Y_UNIT_TEST_SUITE(TestMemIO) {
UNIT_ASSERT(0 == memcmp(buffer, result, strlen(result)));
}
- Y_UNIT_TEST(WriteChars) {
+ Y_UNIT_TEST(WriteChars) {
char buffer[20];
TMemoryOutput output(buffer, sizeof(buffer));
output << '1' << '2' << '3' << '4' << '5' << '6' << '7' << '8' << '9' << '0';
diff --git a/util/stream/multi.cpp b/util/stream/multi.cpp
index 5866bad44a..b2354298a0 100644
--- a/util/stream/multi.cpp
+++ b/util/stream/multi.cpp
@@ -1,7 +1,7 @@
#include "null.h"
#include "multi.h"
-TMultiInput::TMultiInput(IInputStream* f, IInputStream* s) noexcept
+TMultiInput::TMultiInput(IInputStream* f, IInputStream* s) noexcept
: C_(f)
, N_(s)
{
diff --git a/util/stream/multi.h b/util/stream/multi.h
index aad061f23c..8bfd462d99 100644
--- a/util/stream/multi.h
+++ b/util/stream/multi.h
@@ -10,9 +10,9 @@
/**
* A proxy input stream that concatenates two slave streams into one.
*/
-class TMultiInput: public IInputStream {
+class TMultiInput: public IInputStream {
public:
- TMultiInput(IInputStream* f, IInputStream* s) noexcept;
+ TMultiInput(IInputStream* f, IInputStream* s) noexcept;
~TMultiInput() override;
private:
@@ -21,8 +21,8 @@ private:
size_t DoReadTo(TString& st, char ch) override;
private:
- IInputStream* C_;
- IInputStream* N_;
+ IInputStream* C_;
+ IInputStream* N_;
};
/**
diff --git a/util/stream/multi_ut.cpp b/util/stream/multi_ut.cpp
index 2f16772196..fc2553b533 100644
--- a/util/stream/multi_ut.cpp
+++ b/util/stream/multi_ut.cpp
@@ -3,12 +3,12 @@
#include "str.h"
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TestMultiInput) {
+Y_UNIT_TEST_SUITE(TestMultiInput) {
struct TTestCase {
TMemoryInput Input1;
TMemoryInput Input2;
TMultiInput MultiInput;
- TTestCase(const TStringBuf in1, const TStringBuf in2)
+ TTestCase(const TStringBuf in1, const TStringBuf in2)
: Input1(in1)
, Input2(in2)
, MultiInput(&Input1, &Input2)
@@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(TestMultiInput) {
}
};
- Y_UNIT_TEST(TestReadTo) {
+ Y_UNIT_TEST(TestReadTo) {
TString t;
TTestCase simpleCase("0123456789abc", "defghijk");
@@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(TestMultiInput) {
simpleCase.TestReadToResult('z', 5, "ghijk");
}
- Y_UNIT_TEST(TestReadToBetweenStreams) {
+ Y_UNIT_TEST(TestReadToBetweenStreams) {
TTestCase case1("0123456789abc", "defghijk");
case1.TestReadToResult('c', 13, "0123456789ab");
case1.TestReadToResult('k', 8, "defghij");
diff --git a/util/stream/null.h b/util/stream/null.h
index a87df475bc..8c335a9a78 100644
--- a/util/stream/null.h
+++ b/util/stream/null.h
@@ -11,7 +11,7 @@
/**
* Null input stream. Does nothing, contains no data.
*/
-class TNullInput: public IZeroCopyInput {
+class TNullInput: public IZeroCopyInput {
public:
TNullInput() noexcept;
~TNullInput() override;
@@ -25,7 +25,7 @@ private:
/**
* Null output stream. Just ignores whatever is written into it.
*/
-class TNullOutput: public IOutputStream {
+class TNullOutput: public IOutputStream {
public:
TNullOutput() noexcept;
~TNullOutput() override;
diff --git a/util/stream/output.cpp b/util/stream/output.cpp
index a71f46ac48..db81b81b70 100644
--- a/util/stream/output.cpp
+++ b/util/stream/output.cpp
@@ -20,27 +20,27 @@
#include <string_view>
#include <cstdio>
-#if defined(_win_)
+#if defined(_win_)
#include <io.h>
-#endif
+#endif
constexpr size_t MAX_UTF8_BYTES = 4; // UTF-8-encoded code point takes between 1 and 4 bytes
-IOutputStream::IOutputStream() noexcept = default;
+IOutputStream::IOutputStream() noexcept = default;
-IOutputStream::~IOutputStream() = default;
+IOutputStream::~IOutputStream() = default;
-void IOutputStream::DoFlush() {
+void IOutputStream::DoFlush() {
/*
* do nothing
*/
}
-void IOutputStream::DoFinish() {
+void IOutputStream::DoFinish() {
Flush();
}
-void IOutputStream::DoWriteV(const TPart* parts, size_t count) {
+void IOutputStream::DoWriteV(const TPart* parts, size_t count) {
for (size_t i = 0; i < count; ++i) {
const TPart& part = parts[i];
@@ -69,7 +69,7 @@ void Out<wchar32>(IOutputStream& o, wchar32 ch) {
o.Write(buffer, length);
}
-static void WriteString(IOutputStream& o, const wchar16* w, size_t n) {
+static void WriteString(IOutputStream& o, const wchar16* w, size_t n) {
const size_t buflen = (n * MAX_UTF8_BYTES); // * 4 because the conversion functions can convert unicode character into maximum 4 bytes of UTF8
TTempBuf buffer(buflen + 1);
char* const data = buffer.Data();
@@ -90,12 +90,12 @@ static void WriteString(IOutputStream& o, const wchar32* w, size_t n) {
}
template <>
-void Out<TString>(IOutputStream& o, const TString& p) {
+void Out<TString>(IOutputStream& o, const TString& p) {
o.Write(p.data(), p.size());
}
template <>
-void Out<std::string>(IOutputStream& o, const std::string& p) {
+void Out<std::string>(IOutputStream& o, const std::string& p) {
o.Write(p.data(), p.length());
}
@@ -130,7 +130,7 @@ void Out<TUtf32StringBuf>(IOutputStream& o, const TUtf32StringBuf& p) {
}
template <>
-void Out<const wchar16*>(IOutputStream& o, const wchar16* w) {
+void Out<const wchar16*>(IOutputStream& o, const wchar16* w) {
if (w) {
WriteString(o, w, std::char_traits<wchar16>::length(w));
} else {
@@ -148,7 +148,7 @@ void Out<const wchar32*>(IOutputStream& o, const wchar32* w) {
}
template <>
-void Out<TUtf16String>(IOutputStream& o, const TUtf16String& w) {
+void Out<TUtf16String>(IOutputStream& o, const TUtf16String& w) {
WriteString(o, w.c_str(), w.size());
}
@@ -159,19 +159,19 @@ void Out<TUtf32String>(IOutputStream& o, const TUtf32String& w) {
#define DEF_CONV_DEFAULT(type) \
template <> \
- void Out<type>(IOutputStream & o, type p) { \
+ void Out<type>(IOutputStream & o, type p) { \
o << ToString(p); \
}
#define DEF_CONV_CHR(type) \
template <> \
- void Out<type>(IOutputStream & o, type p) { \
+ void Out<type>(IOutputStream & o, type p) { \
o.Write((char)p); \
}
#define DEF_CONV_NUM(type, len) \
template <> \
- void Out<type>(IOutputStream & o, type p) { \
+ void Out<type>(IOutputStream & o, type p) { \
char buf[len]; \
o.Write(buf, ToString(p, buf, sizeof(buf))); \
} \
@@ -211,12 +211,12 @@ void Out<typename std::vector<bool>::reference>(IOutputStream& o, const std::vec
#ifndef TSTRING_IS_STD_STRING
template <>
-void Out<TBasicCharRef<TString>>(IOutputStream& o, const TBasicCharRef<TString>& c) {
+void Out<TBasicCharRef<TString>>(IOutputStream& o, const TBasicCharRef<TString>& c) {
o << static_cast<char>(c);
}
template <>
-void Out<TBasicCharRef<TUtf16String>>(IOutputStream& o, const TBasicCharRef<TUtf16String>& c) {
+void Out<TBasicCharRef<TUtf16String>>(IOutputStream& o, const TBasicCharRef<TUtf16String>& c) {
o << static_cast<wchar16>(c);
}
@@ -227,19 +227,19 @@ void Out<TBasicCharRef<TUtf32String>>(IOutputStream& o, const TBasicCharRef<TUtf
#endif
template <>
-void Out<const void*>(IOutputStream& o, const void* t) {
+void Out<const void*>(IOutputStream& o, const void* t) {
o << Hex(size_t(t));
}
template <>
-void Out<void*>(IOutputStream& o, void* t) {
+void Out<void*>(IOutputStream& o, void* t) {
Out<const void*>(o, t);
}
using TNullPtr = decltype(nullptr);
template <>
-void Out<TNullPtr>(IOutputStream& o, TTypeTraits<TNullPtr>::TFuncParam) {
+void Out<TNullPtr>(IOutputStream& o, TTypeTraits<TNullPtr>::TFuncParam) {
o << TStringBuf("nullptr");
}
@@ -258,7 +258,7 @@ namespace {
public:
using TLogFuncPtr = void (*)(int, const char*, const char*);
- class TAndroidStdOutput: public IOutputStream {
+ class TAndroidStdOutput: public IOutputStream {
public:
inline TAndroidStdOutput(TLogFuncPtr logFuncPtr) noexcept
: Buffer()
@@ -339,7 +339,7 @@ namespace {
#endif // _android_
namespace {
- class TStdOutput: public IOutputStream {
+ class TStdOutput: public IOutputStream {
public:
inline TStdOutput(FILE* f) noexcept
: F_(f)
@@ -355,7 +355,7 @@ namespace {
// On Windows, if 'F_' is console -- 'fwrite' returns count of written characters.
// If, for example, console output codepage is UTF-8, then returned value is
// not equal to 'len'. So, we ignore some 'errno' values...
- if ((errno == 0 || errno == EINVAL || errno == EILSEQ) && _isatty(fileno(F_))) {
+ if ((errno == 0 || errno == EINVAL || errno == EILSEQ) && _isatty(fileno(F_))) {
return;
}
#endif
@@ -401,7 +401,7 @@ namespace {
};
}
-IOutputStream& NPrivate::StdErrStream() noexcept {
+IOutputStream& NPrivate::StdErrStream() noexcept {
#if defined(_android_)
if (TAndroidStdIOStreams::Enabled) {
return TAndroidStdIOStreams::Instance().Err;
@@ -410,7 +410,7 @@ IOutputStream& NPrivate::StdErrStream() noexcept {
return TStdIOStreams::Instance().Err;
}
-IOutputStream& NPrivate::StdOutStream() noexcept {
+IOutputStream& NPrivate::StdOutStream() noexcept {
#if defined(_android_)
if (TAndroidStdIOStreams::Enabled) {
return TAndroidStdIOStreams::Instance().Out;
@@ -423,6 +423,6 @@ void RedirectStdioToAndroidLog(bool redirect) {
#if defined(_android_)
TAndroidStdIOStreams::Enabled = redirect;
#else
- Y_UNUSED(redirect);
+ Y_UNUSED(redirect);
#endif
}
diff --git a/util/stream/output.h b/util/stream/output.h
index 3b40c4396f..00eef50b95 100644
--- a/util/stream/output.h
+++ b/util/stream/output.h
@@ -1,6 +1,6 @@
#pragma once
-#include "fwd.h"
+#include "fwd.h"
#include "labeled.h"
#include <util/generic/noncopyable.h>
@@ -18,7 +18,7 @@
/**
* Abstract output stream.
*/
-class IOutputStream: public TNonCopyable {
+class IOutputStream: public TNonCopyable {
public:
/**
* Data block for output.
@@ -30,7 +30,7 @@ public:
{
}
- inline TPart(const TStringBuf s) noexcept
+ inline TPart(const TStringBuf s) noexcept
: buf(s.data())
, len(s.size())
{
@@ -52,13 +52,13 @@ public:
size_t len;
};
- IOutputStream() noexcept;
- virtual ~IOutputStream();
+ IOutputStream() noexcept;
+ virtual ~IOutputStream();
- IOutputStream(IOutputStream&&) noexcept {
+ IOutputStream(IOutputStream&&) noexcept {
}
- IOutputStream& operator=(IOutputStream&&) noexcept {
+ IOutputStream& operator=(IOutputStream&&) noexcept {
return *this;
};
@@ -79,7 +79,7 @@ public:
*
* @param st String to write.
*/
- inline void Write(const TStringBuf st) {
+ inline void Write(const TStringBuf st) {
Write(st.data(), st.size());
}
@@ -171,7 +171,7 @@ protected:
};
/**
- * `operator<<` for `IOutputStream` by default delegates to this function.
+ * `operator<<` for `IOutputStream` by default delegates to this function.
*
* Note that while `operator<<` uses overloading (and thus argument-dependent
* lookup), `Out` uses template specializations. This makes it possible to
@@ -186,14 +186,14 @@ protected:
* @param value Value to write.
*/
template <class T>
-void Out(IOutputStream& out, typename TTypeTraits<T>::TFuncParam value);
+void Out(IOutputStream& out, typename TTypeTraits<T>::TFuncParam value);
-#define Y_DECLARE_OUT_SPEC(MODIF, T, stream, value) \
- template <> \
- MODIF void Out<T>(IOutputStream & stream, TTypeTraits<T>::TFuncParam value)
+#define Y_DECLARE_OUT_SPEC(MODIF, T, stream, value) \
+ template <> \
+ MODIF void Out<T>(IOutputStream & stream, TTypeTraits<T>::TFuncParam value)
template <>
-inline void Out<const char*>(IOutputStream& o, const char* t) {
+inline void Out<const char*>(IOutputStream& o, const char* t) {
if (t) {
o.Write(t);
} else {
@@ -202,24 +202,24 @@ inline void Out<const char*>(IOutputStream& o, const char* t) {
}
template <>
-void Out<const wchar16*>(IOutputStream& o, const wchar16* w);
+void Out<const wchar16*>(IOutputStream& o, const wchar16* w);
template <>
void Out<const wchar32*>(IOutputStream& o, const wchar32* w);
-static inline IOutputStream& operator<<(IOutputStream& o, TStreamManipulator m) {
+static inline IOutputStream& operator<<(IOutputStream& o, TStreamManipulator m) {
m(o);
return o;
}
-static inline IOutputStream& operator<<(IOutputStream& o, const char* t) {
+static inline IOutputStream& operator<<(IOutputStream& o, const char* t) {
Out<const char*>(o, t);
return o;
}
-static inline IOutputStream& operator<<(IOutputStream& o, char* t) {
+static inline IOutputStream& operator<<(IOutputStream& o, char* t) {
Out<const char*>(o, t);
return o;
@@ -239,12 +239,12 @@ static inline std::enable_if_t<!std::is_scalar<T>::value, IOutputStream&> operat
return o;
}
-static inline IOutputStream& operator<<(IOutputStream& o, const wchar16* t) {
+static inline IOutputStream& operator<<(IOutputStream& o, const wchar16* t) {
Out<const wchar16*>(o, t);
return o;
}
-static inline IOutputStream& operator<<(IOutputStream& o, wchar16* t) {
+static inline IOutputStream& operator<<(IOutputStream& o, wchar16* t) {
Out<const wchar16*>(o, t);
return o;
}
@@ -260,8 +260,8 @@ static inline IOutputStream& operator<<(IOutputStream& o, wchar32* t) {
}
namespace NPrivate {
- IOutputStream& StdOutStream() noexcept;
- IOutputStream& StdErrStream() noexcept;
+ IOutputStream& StdOutStream() noexcept;
+ IOutputStream& StdErrStream() noexcept;
}
/**
@@ -282,14 +282,14 @@ namespace NPrivate {
/**
* End-of-line output manipulator, basically the same as `std::endl`.
*/
-static inline void Endl(IOutputStream& o) {
+static inline void Endl(IOutputStream& o) {
(o << '\n').Flush();
}
/**
* Flushing stream manipulator, basically the same as `std::flush`.
*/
-static inline void Flush(IOutputStream& o) {
+static inline void Flush(IOutputStream& o) {
o.Flush();
}
diff --git a/util/stream/pipe.cpp b/util/stream/pipe.cpp
index ff5b778802..51be1934a7 100644
--- a/util/stream/pipe.cpp
+++ b/util/stream/pipe.cpp
@@ -8,7 +8,7 @@
class TPipeBase::TImpl {
public:
inline TImpl(const TString& command, const char* mode)
- : Pipe_(nullptr)
+ : Pipe_(nullptr)
{
#ifndef _freebsd_
if (strcmp(mode, "r+") == 0) {
@@ -16,13 +16,13 @@ public:
}
#endif
Pipe_ = ::popen(command.data(), mode);
- if (Pipe_ == nullptr) {
+ if (Pipe_ == nullptr) {
ythrow TSystemError() << "failed to open pipe: " << command.Quote();
}
}
inline ~TImpl() {
- if (Pipe_ != nullptr) {
+ if (Pipe_ != nullptr) {
::pclose(Pipe_);
}
}
@@ -44,14 +44,14 @@ TPipeInput::TPipeInput(const TString& command)
}
size_t TPipeInput::DoRead(void* buf, size_t len) {
- if (Impl_->Pipe_ == nullptr) {
+ if (Impl_->Pipe_ == nullptr) {
return 0;
}
size_t bytesRead = ::fread(buf, 1, len, Impl_->Pipe_);
if (bytesRead == 0) {
int exitStatus = ::pclose(Impl_->Pipe_);
- Impl_->Pipe_ = nullptr;
+ Impl_->Pipe_ = nullptr;
if (exitStatus == -1) {
ythrow TSystemError() << "pclose() failed";
} else if (exitStatus != 0) {
@@ -67,14 +67,14 @@ TPipeOutput::TPipeOutput(const TString& command)
}
void TPipeOutput::DoWrite(const void* buf, size_t len) {
- if (Impl_->Pipe_ == nullptr || len != ::fwrite(buf, 1, len, Impl_->Pipe_)) {
+ if (Impl_->Pipe_ == nullptr || len != ::fwrite(buf, 1, len, Impl_->Pipe_)) {
ythrow TSystemError() << "fwrite failed";
}
}
void TPipeOutput::Close() {
int exitStatus = ::pclose(Impl_->Pipe_);
- Impl_->Pipe_ = nullptr;
+ Impl_->Pipe_ = nullptr;
if (exitStatus == -1) {
ythrow TSystemError() << "pclose() failed";
} else if (exitStatus != 0) {
diff --git a/util/stream/pipe.h b/util/stream/pipe.h
index e736860a3a..18525b9517 100644
--- a/util/stream/pipe.h
+++ b/util/stream/pipe.h
@@ -88,7 +88,7 @@ protected:
/**
* Input stream that binds to a standard output stream of an existing process.
*/
-class TPipedInput: public TPipedBase, public IInputStream {
+class TPipedInput: public TPipedBase, public IInputStream {
public:
TPipedInput(PIPEHANDLE fd);
~TPipedInput() override;
@@ -100,7 +100,7 @@ private:
/**
* Output stream that binds to a standard input stream of an existing process.
*/
-class TPipedOutput: public TPipedBase, public IOutputStream {
+class TPipedOutput: public TPipedBase, public IOutputStream {
public:
TPipedOutput(PIPEHANDLE fd);
~TPipedOutput() override;
diff --git a/util/stream/printf.cpp b/util/stream/printf.cpp
index f7adaa2b2a..f3eeca7afc 100644
--- a/util/stream/printf.cpp
+++ b/util/stream/printf.cpp
@@ -1,11 +1,11 @@
-#include "output.h"
+#include "output.h"
#include "printf.h"
#include <util/generic/scope.h>
#include <util/memory/tempbuf.h>
#include <util/generic/yexception.h>
-size_t Printf(IOutputStream& out, const char* fmt, ...) {
+size_t Printf(IOutputStream& out, const char* fmt, ...) {
va_list lst;
va_start(lst, fmt);
@@ -16,7 +16,7 @@ size_t Printf(IOutputStream& out, const char* fmt, ...) {
return Printf(out, fmt, lst);
}
-static inline size_t TryPrintf(void* ptr, size_t len, IOutputStream& out, const char* fmt, va_list params) {
+static inline size_t TryPrintf(void* ptr, size_t len, IOutputStream& out, const char* fmt, va_list params) {
va_list lst;
va_copy(lst, params);
const int ret = vsnprintf((char*)ptr, len, fmt, lst);
@@ -33,7 +33,7 @@ static inline size_t TryPrintf(void* ptr, size_t len, IOutputStream& out, const
return (size_t)ret;
}
-size_t Printf(IOutputStream& out, const char* fmt, va_list params) {
+size_t Printf(IOutputStream& out, const char* fmt, va_list params) {
size_t guess = 0;
while (true) {
diff --git a/util/stream/printf.h b/util/stream/printf.h
index c6199a15ef..1c7ddc0664 100644
--- a/util/stream/printf.h
+++ b/util/stream/printf.h
@@ -2,7 +2,7 @@
#include <util/system/compat.h>
-class IOutputStream;
+class IOutputStream;
/**
* Stream-based `printf` function. Prints formatted data into the provided stream.
@@ -12,7 +12,7 @@ class IOutputStream;
* @param fmt Format string.
* @param ... Additional arguments.
*/
-size_t Y_PRINTF_FORMAT(2, 3) Printf(IOutputStream& out, const char* fmt, ...);
+size_t Y_PRINTF_FORMAT(2, 3) Printf(IOutputStream& out, const char* fmt, ...);
/**
* Stream-based `vprintf` function. Prints formatted data from variable argument
@@ -22,4 +22,4 @@ size_t Y_PRINTF_FORMAT(2, 3) Printf(IOutputStream& out, const char* fmt, ...);
* @param fmt Format string.
* @param params Additional arguments as a variable argument list.
*/
-size_t Y_PRINTF_FORMAT(2, 0) Printf(IOutputStream& out, const char* fmt, va_list params);
+size_t Y_PRINTF_FORMAT(2, 0) Printf(IOutputStream& out, const char* fmt, va_list params);
diff --git a/util/stream/printf_ut.cpp b/util/stream/printf_ut.cpp
index fbfee58af4..0eab167062 100644
--- a/util/stream/printf_ut.cpp
+++ b/util/stream/printf_ut.cpp
@@ -1,13 +1,13 @@
-#include "null.h"
+#include "null.h"
#include "printf.h"
-#include "str.h"
+#include "str.h"
#include <util/generic/string.h>
-
+
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TStreamPrintfTest) {
- Y_UNIT_TEST(TestPrintf) {
+Y_UNIT_TEST_SUITE(TStreamPrintfTest) {
+ Y_UNIT_TEST(TestPrintf) {
TStringStream ss;
UNIT_ASSERT_EQUAL(Printf(ss, "qw %s %d", "er", 1), 7);
@@ -18,11 +18,11 @@ Y_UNIT_TEST_SUITE(TStreamPrintfTest) {
#pragma GCC diagnostic ignored "-Wformat-zero-length"
#endif // __GNUC__
- Y_UNIT_TEST(TestZeroString) {
+ Y_UNIT_TEST(TestZeroString) {
UNIT_ASSERT_EQUAL(Printf(Cnull, ""), 0);
}
- Y_UNIT_TEST(TestLargePrintf) {
+ Y_UNIT_TEST(TestLargePrintf) {
TString s = NUnitTest::RandomString(1000000);
TStringStream ss;
diff --git a/util/stream/str.h b/util/stream/str.h
index 07dc24861a..028bd572c0 100644
--- a/util/stream/str.h
+++ b/util/stream/str.h
@@ -15,7 +15,7 @@
/**
* Input stream for reading data from a string.
*/
-class TStringInput: public IZeroCopyInputFastReadTo {
+class TStringInput: public IZeroCopyInputFastReadTo {
public:
/**
* Constructs a string input stream that reads character data from the
@@ -109,7 +109,7 @@ private:
*/
class TStringStream: private TEmbedPolicy<TString>, public TStringInput, public TStringOutput {
using TEmbeddedString = TEmbedPolicy<TString>;
-
+
public:
inline TStringStream()
: TEmbeddedString()
diff --git a/util/stream/str_ut.cpp b/util/stream/str_ut.cpp
index 930c5eac95..fc6b46c31a 100644
--- a/util/stream/str_ut.cpp
+++ b/util/stream/str_ut.cpp
@@ -7,7 +7,7 @@ template <typename T>
const T ReturnConstTemp();
Y_UNIT_TEST_SUITE(TStringInputOutputTest) {
- Y_UNIT_TEST(Lvalue) {
+ Y_UNIT_TEST(Lvalue) {
TString str = "Hello, World!";
TStringInput input(str);
@@ -16,7 +16,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) {
UNIT_ASSERT_VALUES_EQUAL(result, str);
}
- Y_UNIT_TEST(ConstRef) {
+ Y_UNIT_TEST(ConstRef) {
TString str = "Hello, World!";
const TString& r = str;
TStringInput input(r);
@@ -26,7 +26,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) {
UNIT_ASSERT_VALUES_EQUAL(result, str);
}
- Y_UNIT_TEST(NonConstRef) {
+ Y_UNIT_TEST(NonConstRef) {
TString str = "Hello, World!";
TString& r = str;
TStringInput input(r);
@@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) {
UNIT_ASSERT_VALUES_EQUAL(result, str);
}
- Y_UNIT_TEST(Transfer) {
+ Y_UNIT_TEST(Transfer) {
TString inputString = "some_string";
TStringInput input(inputString);
@@ -48,7 +48,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) {
UNIT_ASSERT_VALUES_EQUAL(inputString, outputString);
}
- Y_UNIT_TEST(SkipReadAll) {
+ Y_UNIT_TEST(SkipReadAll) {
TString string0 = "All animals are equal, but some animals are more equal than others.";
TString string1;
@@ -68,7 +68,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) {
UNIT_ASSERT_VALUES_EQUAL(string2, string1.substr(5));
}
- Y_UNIT_TEST(OperatorBool) {
+ Y_UNIT_TEST(OperatorBool) {
TStringStream str;
UNIT_ASSERT(!str);
str << "data";
@@ -77,7 +77,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) {
UNIT_ASSERT(!str);
}
- Y_UNIT_TEST(TestReadTo) {
+ Y_UNIT_TEST(TestReadTo) {
TString s("0123456789abc");
TString t;
@@ -113,7 +113,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) {
UNIT_ASSERT_STRINGS_EQUAL(str1, str2);
}
- Y_UNIT_TEST(Write) {
+ Y_UNIT_TEST(Write) {
TString str;
TStringOutput output(str);
output << "1"
@@ -129,7 +129,7 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) {
"55555");
}
- Y_UNIT_TEST(WriteChars) {
+ Y_UNIT_TEST(WriteChars) {
TString str;
TStringOutput output(str);
output << '1' << '2' << '3' << '4' << '5' << '6' << '7' << '8' << '9' << '0';
diff --git a/util/stream/tee.cpp b/util/stream/tee.cpp
index ffa597648a..99873b95ba 100644
--- a/util/stream/tee.cpp
+++ b/util/stream/tee.cpp
@@ -1,6 +1,6 @@
#include "tee.h"
-TTeeOutput::TTeeOutput(IOutputStream* l, IOutputStream* r) noexcept
+TTeeOutput::TTeeOutput(IOutputStream* l, IOutputStream* r) noexcept
: L_(l)
, R_(r)
{
diff --git a/util/stream/tee.h b/util/stream/tee.h
index 83711d7059..c69e232fb9 100644
--- a/util/stream/tee.h
+++ b/util/stream/tee.h
@@ -10,9 +10,9 @@
/**
* A proxy output stream that writes into two slave streams simultaneously.
*/
-class TTeeOutput: public IOutputStream {
+class TTeeOutput: public IOutputStream {
public:
- TTeeOutput(IOutputStream* l, IOutputStream* r) noexcept;
+ TTeeOutput(IOutputStream* l, IOutputStream* r) noexcept;
~TTeeOutput() override;
private:
@@ -21,8 +21,8 @@ private:
void DoFinish() override;
private:
- IOutputStream* L_;
- IOutputStream* R_;
+ IOutputStream* L_;
+ IOutputStream* R_;
};
/** @} */
diff --git a/util/stream/tempbuf.cpp b/util/stream/tempbuf.cpp
index 4fd8fc8112..801a1fabb0 100644
--- a/util/stream/tempbuf.cpp
+++ b/util/stream/tempbuf.cpp
@@ -7,7 +7,7 @@ namespace {
}
void TTempBufOutput::DoWrite(const void* data, size_t len) {
- if (Y_LIKELY(len <= Left())) {
+ if (Y_LIKELY(len <= Left())) {
Append(data, len);
} else {
const size_t filled = Filled();
diff --git a/util/stream/tokenizer.h b/util/stream/tokenizer.h
index bc27650ce4..b2398efdd1 100644
--- a/util/stream/tokenizer.h
+++ b/util/stream/tokenizer.h
@@ -2,10 +2,10 @@
#include "input.h"
-#include <util/generic/buffer.h>
-#include <util/generic/mem_copy.h>
-#include <util/generic/strbuf.h>
-#include <util/system/compiler.h>
+#include <util/generic/buffer.h>
+#include <util/generic/mem_copy.h>
+#include <util/generic/strbuf.h>
+#include <util/system/compiler.h>
#include <util/system/yassert.h>
/**
@@ -20,12 +20,12 @@
* @tparam TEndOfToken Predicate for token delimiter characters.
* @see TEol
*/
-template <typename TEndOfToken>
+template <typename TEndOfToken>
class TStreamTokenizer {
public:
class TIterator {
public:
- inline TIterator(TStreamTokenizer* const parent)
+ inline TIterator(TStreamTokenizer* const parent)
: Parent_(parent)
, AtEnd_(!Parent_->Next(Data_, Len_))
{
@@ -53,21 +53,21 @@ public:
return !(*this == l);
}
- /**
- * @return Return null-terminated character array with current token.
- * The pointer may be invalid after iterator increment.
- */
+ /**
+ * @return Return null-terminated character array with current token.
+ * The pointer may be invalid after iterator increment.
+ */
inline const char* Data() const noexcept {
- Y_ASSERT(!AtEnd_);
+ Y_ASSERT(!AtEnd_);
return Data_;
}
- /**
- * @return Length of current token.
- */
+ /**
+ * @return Length of current token.
+ */
inline size_t Length() const noexcept {
- Y_ASSERT(!AtEnd_);
+ Y_ASSERT(!AtEnd_);
return Len_;
}
@@ -77,27 +77,27 @@ public:
}
inline TStringBuf operator*() noexcept {
- return TStringBuf{Data_, Len_};
+ return TStringBuf{Data_, Len_};
}
private:
inline void Next() {
- Y_ASSERT(Parent_);
+ Y_ASSERT(Parent_);
AtEnd_ = !Parent_->Next(Data_, Len_);
}
private:
- TStreamTokenizer* const Parent_;
+ TStreamTokenizer* const Parent_;
char* Data_;
size_t Len_;
bool AtEnd_;
};
- inline TStreamTokenizer(IInputStream* const input, const TEndOfToken& eot = TEndOfToken(),
- const size_t initial = 1024)
+ inline TStreamTokenizer(IInputStream* const input, const TEndOfToken& eot = TEndOfToken(),
+ const size_t initial = 1024)
: Input_(input)
- , Buf_(initial)
+ , Buf_(initial)
, Cur_(BufBegin())
, End_(BufBegin())
, Eot_(eot)
@@ -112,7 +112,7 @@ public:
do {
while (it != End_) {
if (Eot_(*it)) {
- *it = '\0';
+ *it = '\0';
buf = Cur_;
len = it - Cur_;
@@ -125,7 +125,7 @@ public:
}
if (Fill() == 0 && End_ != BufEnd()) {
- *it = '\0';
+ *it = '\0';
buf = Cur_;
len = it - Cur_;
@@ -135,25 +135,25 @@ public:
}
} while (it != BufEnd());
- Y_ASSERT(it == BufEnd());
- Y_ASSERT(End_ == BufEnd());
+ Y_ASSERT(it == BufEnd());
+ Y_ASSERT(End_ == BufEnd());
const size_t blen = End_ - Cur_;
if (Cur_ == BufBegin()) {
- Y_ASSERT(blen == Buf_.Capacity());
+ Y_ASSERT(blen == Buf_.Capacity());
/*
* do reallocate
*/
- Buf_.Reserve(Buf_.Capacity() * 4);
+ Buf_.Reserve(Buf_.Capacity() * 4);
CheckBuf();
} else {
/*
* do move
*/
- MemMove(BufBegin(), Cur_, blen);
+ MemMove(BufBegin(), Cur_, blen);
}
Cur_ = BufBegin();
@@ -162,14 +162,14 @@ public:
}
}
- inline TIterator begin() {
- return TIterator{this};
- }
-
+ inline TIterator begin() {
+ return TIterator{this};
+ }
+
inline TIterator end() noexcept {
- return {};
- }
-
+ return {};
+ }
+
private:
inline size_t Fill() {
const size_t avail = BufEnd() - End_;
@@ -181,22 +181,22 @@ private:
}
inline char* BufBegin() noexcept {
- return Buf_.Data();
+ return Buf_.Data();
}
inline char* BufEnd() noexcept {
- return Buf_.Data() + Buf_.Capacity();
+ return Buf_.Data() + Buf_.Capacity();
}
inline void CheckBuf() const {
- if (!Buf_.Data()) {
+ if (!Buf_.Data()) {
throw std::bad_alloc();
}
}
private:
- IInputStream* const Input_;
- TBuffer Buf_;
+ IInputStream* const Input_;
+ TBuffer Buf_;
char* Cur_;
char* End_;
TEndOfToken Eot_;
diff --git a/util/stream/tokenizer_ut.cpp b/util/stream/tokenizer_ut.cpp
index 37bb12e7d2..afc566da86 100644
--- a/util/stream/tokenizer_ut.cpp
+++ b/util/stream/tokenizer_ut.cpp
@@ -1,264 +1,264 @@
#include <library/cpp/testing/unittest/registar.h>
-
-#include <util/generic/array_size.h>
-#include <util/generic/strbuf.h>
-
-#include "mem.h"
-#include "null.h"
-#include "tokenizer.h"
-
-static inline void CheckIfNullTerminated(const TStringBuf str) {
+
+#include <util/generic/array_size.h>
+#include <util/generic/strbuf.h>
+
+#include "mem.h"
+#include "null.h"
+#include "tokenizer.h"
+
+static inline void CheckIfNullTerminated(const TStringBuf str) {
UNIT_ASSERT_VALUES_EQUAL('\0', *(str.data() + str.size()));
-}
-
-Y_UNIT_TEST_SUITE(TStreamTokenizerTests) {
- Y_UNIT_TEST(EmptyStreamTest) {
- auto&& input = TNullInput{};
- auto&& tokenizer = TStreamTokenizer<TEol>{&input};
- auto tokensCount = size_t{};
- for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
- CheckIfNullTerminated(TStringBuf{it->Data(), it->Length()});
- ++tokensCount;
- }
- UNIT_ASSERT_VALUES_EQUAL(0, tokensCount);
- }
-
- Y_UNIT_TEST(EmptyTokensTest) {
- const char data[] = "\n\n";
- const auto dataSize = Y_ARRAY_SIZE(data) - 1;
- auto&& input = TMemoryInput{data, dataSize};
- auto&& tokenizer = TStreamTokenizer<TEol>{&input};
- auto tokensCount = size_t{};
- for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
- CheckIfNullTerminated(TStringBuf{it->Data(), it->Length()});
- UNIT_ASSERT_VALUES_EQUAL(0, it->Length());
- ++tokensCount;
- }
- UNIT_ASSERT_VALUES_EQUAL(2, tokensCount);
- }
-
- Y_UNIT_TEST(LastTokenendDoesntSatisfyPredicateTest) {
- const char data[] = "abc\ndef\nxxxxxx";
- const auto dataSize = Y_ARRAY_SIZE(data) - 1;
+}
+
+Y_UNIT_TEST_SUITE(TStreamTokenizerTests) {
+ Y_UNIT_TEST(EmptyStreamTest) {
+ auto&& input = TNullInput{};
+ auto&& tokenizer = TStreamTokenizer<TEol>{&input};
+ auto tokensCount = size_t{};
+ for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
+ CheckIfNullTerminated(TStringBuf{it->Data(), it->Length()});
+ ++tokensCount;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(0, tokensCount);
+ }
+
+ Y_UNIT_TEST(EmptyTokensTest) {
+ const char data[] = "\n\n";
+ const auto dataSize = Y_ARRAY_SIZE(data) - 1;
+ auto&& input = TMemoryInput{data, dataSize};
+ auto&& tokenizer = TStreamTokenizer<TEol>{&input};
+ auto tokensCount = size_t{};
+ for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
+ CheckIfNullTerminated(TStringBuf{it->Data(), it->Length()});
+ UNIT_ASSERT_VALUES_EQUAL(0, it->Length());
+ ++tokensCount;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(2, tokensCount);
+ }
+
+ Y_UNIT_TEST(LastTokenendDoesntSatisfyPredicateTest) {
+ const char data[] = "abc\ndef\nxxxxxx";
+ const auto dataSize = Y_ARRAY_SIZE(data) - 1;
const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")};
- const auto tokensSize = Y_ARRAY_SIZE(tokens);
- auto&& input = TMemoryInput{data, dataSize};
- auto&& tokenizer = TStreamTokenizer<TEol>{&input};
- auto tokensCount = size_t{};
- for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
- UNIT_ASSERT(tokensCount < tokensSize);
- const auto token = TStringBuf{it->Data(), it->Length()};
- CheckIfNullTerminated(token);
- UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
- ++tokensCount;
- }
- UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
- }
-
- Y_UNIT_TEST(FirstTokenIsEmptyTest) {
- const char data[] = "\ndef\nxxxxxx";
- const auto dataSize = Y_ARRAY_SIZE(data) - 1;
+ const auto tokensSize = Y_ARRAY_SIZE(tokens);
+ auto&& input = TMemoryInput{data, dataSize};
+ auto&& tokenizer = TStreamTokenizer<TEol>{&input};
+ auto tokensCount = size_t{};
+ for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
+ UNIT_ASSERT(tokensCount < tokensSize);
+ const auto token = TStringBuf{it->Data(), it->Length()};
+ CheckIfNullTerminated(token);
+ UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
+ ++tokensCount;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
+ }
+
+ Y_UNIT_TEST(FirstTokenIsEmptyTest) {
+ const char data[] = "\ndef\nxxxxxx";
+ const auto dataSize = Y_ARRAY_SIZE(data) - 1;
const TStringBuf tokens[] = {TStringBuf(), TStringBuf("def"), TStringBuf("xxxxxx")};
- const auto tokensSize = Y_ARRAY_SIZE(tokens);
- auto&& input = TMemoryInput{data, dataSize};
- auto&& tokenizer = TStreamTokenizer<TEol>{&input};
- auto tokensCount = size_t{};
- for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
- UNIT_ASSERT(tokensCount < tokensSize);
- const auto token = TStringBuf{it->Data(), it->Length()};
- CheckIfNullTerminated(token);
- UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
- ++tokensCount;
- }
- UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
- }
-
- Y_UNIT_TEST(PredicateDoesntMatch) {
- const char data[] = "1234567890-=!@#$%^&*()_+QWERTYUIOP{}qwertyuiop[]ASDFGHJKL:";
- const auto dataSize = Y_ARRAY_SIZE(data) - 1;
- auto&& input = TMemoryInput{data, dataSize};
- auto&& tokenizer = TStreamTokenizer<TEol>{&input};
- auto tokensCount = size_t{};
- for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
- const auto token = TStringBuf{it->Data(), it->Length()};
- CheckIfNullTerminated(token);
- UNIT_ASSERT_VALUES_EQUAL(data, token);
- ++tokensCount;
- }
- UNIT_ASSERT_VALUES_EQUAL(1, tokensCount);
- }
-
- Y_UNIT_TEST(SimpleTest) {
- const char data[] = "qwerty\n1234567890\n";
- const auto dataSize = Y_ARRAY_SIZE(data) - 1;
+ const auto tokensSize = Y_ARRAY_SIZE(tokens);
+ auto&& input = TMemoryInput{data, dataSize};
+ auto&& tokenizer = TStreamTokenizer<TEol>{&input};
+ auto tokensCount = size_t{};
+ for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
+ UNIT_ASSERT(tokensCount < tokensSize);
+ const auto token = TStringBuf{it->Data(), it->Length()};
+ CheckIfNullTerminated(token);
+ UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
+ ++tokensCount;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
+ }
+
+ Y_UNIT_TEST(PredicateDoesntMatch) {
+ const char data[] = "1234567890-=!@#$%^&*()_+QWERTYUIOP{}qwertyuiop[]ASDFGHJKL:";
+ const auto dataSize = Y_ARRAY_SIZE(data) - 1;
+ auto&& input = TMemoryInput{data, dataSize};
+ auto&& tokenizer = TStreamTokenizer<TEol>{&input};
+ auto tokensCount = size_t{};
+ for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
+ const auto token = TStringBuf{it->Data(), it->Length()};
+ CheckIfNullTerminated(token);
+ UNIT_ASSERT_VALUES_EQUAL(data, token);
+ ++tokensCount;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(1, tokensCount);
+ }
+
+ Y_UNIT_TEST(SimpleTest) {
+ const char data[] = "qwerty\n1234567890\n";
+ const auto dataSize = Y_ARRAY_SIZE(data) - 1;
const TStringBuf tokens[] = {TStringBuf("qwerty"), TStringBuf("1234567890")};
- const auto tokensSize = Y_ARRAY_SIZE(tokens);
- auto&& input = TMemoryInput{data, dataSize};
- auto&& tokenizer = TStreamTokenizer<TEol>{&input};
- auto tokensCount = size_t{};
- for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
- UNIT_ASSERT(tokensCount < tokensSize);
- const auto token = TStringBuf{it->Data(), it->Length()};
- CheckIfNullTerminated(token);
- UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
- ++tokensCount;
- }
- UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
- }
-
- Y_UNIT_TEST(CustomPredicateTest) {
- struct TIsVerticalBar {
+ const auto tokensSize = Y_ARRAY_SIZE(tokens);
+ auto&& input = TMemoryInput{data, dataSize};
+ auto&& tokenizer = TStreamTokenizer<TEol>{&input};
+ auto tokensCount = size_t{};
+ for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
+ UNIT_ASSERT(tokensCount < tokensSize);
+ const auto token = TStringBuf{it->Data(), it->Length()};
+ CheckIfNullTerminated(token);
+ UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
+ ++tokensCount;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
+ }
+
+ Y_UNIT_TEST(CustomPredicateTest) {
+ struct TIsVerticalBar {
inline bool operator()(const char ch) const noexcept {
- return '|' == ch;
- }
- };
-
- const char data[] = "abc|def|xxxxxx";
- const auto dataSize = Y_ARRAY_SIZE(data) - 1;
+ return '|' == ch;
+ }
+ };
+
+ const char data[] = "abc|def|xxxxxx";
+ const auto dataSize = Y_ARRAY_SIZE(data) - 1;
const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")};
- const auto tokensSize = Y_ARRAY_SIZE(tokens);
- auto&& input = TMemoryInput{data, dataSize};
- auto&& tokenizer = TStreamTokenizer<TIsVerticalBar>{&input};
- auto tokensCount = size_t{};
- for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
- UNIT_ASSERT(tokensCount < tokensSize);
- const auto token = TStringBuf{it->Data(), it->Length()};
- CheckIfNullTerminated(token);
- UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
- ++tokensCount;
- }
- UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
- }
-
- Y_UNIT_TEST(CustomPredicateSecondTest) {
- struct TIsVerticalBar {
+ const auto tokensSize = Y_ARRAY_SIZE(tokens);
+ auto&& input = TMemoryInput{data, dataSize};
+ auto&& tokenizer = TStreamTokenizer<TIsVerticalBar>{&input};
+ auto tokensCount = size_t{};
+ for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
+ UNIT_ASSERT(tokensCount < tokensSize);
+ const auto token = TStringBuf{it->Data(), it->Length()};
+ CheckIfNullTerminated(token);
+ UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
+ ++tokensCount;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
+ }
+
+ Y_UNIT_TEST(CustomPredicateSecondTest) {
+ struct TIsVerticalBar {
inline bool operator()(const char ch) const noexcept {
- return '|' == ch || ',' == ch;
- }
- };
-
- const char data[] = "abc|def|xxxxxx,abc|def|xxxxxx";
- const auto dataSize = Y_ARRAY_SIZE(data) - 1;
+ return '|' == ch || ',' == ch;
+ }
+ };
+
+ const char data[] = "abc|def|xxxxxx,abc|def|xxxxxx";
+ const auto dataSize = Y_ARRAY_SIZE(data) - 1;
const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx"),
TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")};
- const auto tokensSize = Y_ARRAY_SIZE(tokens);
- auto&& input = TMemoryInput{data, dataSize};
- auto&& tokenizer = TStreamTokenizer<TIsVerticalBar>{&input};
- auto tokensCount = size_t{};
- for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
- UNIT_ASSERT(tokensCount < tokensSize);
- const auto token = TStringBuf{it->Data(), it->Length()};
- CheckIfNullTerminated(token);
- UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
- ++tokensCount;
- }
- UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
- }
-
- Y_UNIT_TEST(FalsePredicateTest) {
- struct TAlwaysFalse {
+ const auto tokensSize = Y_ARRAY_SIZE(tokens);
+ auto&& input = TMemoryInput{data, dataSize};
+ auto&& tokenizer = TStreamTokenizer<TIsVerticalBar>{&input};
+ auto tokensCount = size_t{};
+ for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
+ UNIT_ASSERT(tokensCount < tokensSize);
+ const auto token = TStringBuf{it->Data(), it->Length()};
+ CheckIfNullTerminated(token);
+ UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
+ ++tokensCount;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
+ }
+
+ Y_UNIT_TEST(FalsePredicateTest) {
+ struct TAlwaysFalse {
inline bool operator()(const char) const noexcept {
- return false;
- }
- };
-
- const char data[] = "1234567890-=!@#$%^&*()_+QWERTYUIOP{}qwertyuiop[]ASDFGHJKL:";
- const auto dataSize = Y_ARRAY_SIZE(data) - 1;
- auto&& input = TMemoryInput{data, dataSize};
- auto&& tokenizer = TStreamTokenizer<TAlwaysFalse>{&input};
- auto tokensCount = size_t{};
- for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
- const auto token = TStringBuf{it->Data(), it->Length()};
- CheckIfNullTerminated(token);
- UNIT_ASSERT_VALUES_EQUAL(data, token);
- ++tokensCount;
- }
- UNIT_ASSERT_VALUES_EQUAL(1, tokensCount);
- }
-
- Y_UNIT_TEST(TruePredicateTest) {
- struct TAlwaysTrue {
+ return false;
+ }
+ };
+
+ const char data[] = "1234567890-=!@#$%^&*()_+QWERTYUIOP{}qwertyuiop[]ASDFGHJKL:";
+ const auto dataSize = Y_ARRAY_SIZE(data) - 1;
+ auto&& input = TMemoryInput{data, dataSize};
+ auto&& tokenizer = TStreamTokenizer<TAlwaysFalse>{&input};
+ auto tokensCount = size_t{};
+ for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
+ const auto token = TStringBuf{it->Data(), it->Length()};
+ CheckIfNullTerminated(token);
+ UNIT_ASSERT_VALUES_EQUAL(data, token);
+ ++tokensCount;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(1, tokensCount);
+ }
+
+ Y_UNIT_TEST(TruePredicateTest) {
+ struct TAlwaysTrue {
inline bool operator()(const char) const noexcept {
- return true;
- }
- };
-
- const char data[] = "1234567890-=!@#$%^&*()_+QWERTYUIOP{}qwertyuiop[]ASDFGHJKL:";
- const auto dataSize = Y_ARRAY_SIZE(data) - 1;
- auto&& input = TMemoryInput{data, dataSize};
- auto&& tokenizer = TStreamTokenizer<TAlwaysTrue>{&input};
- auto tokensCount = size_t{};
- for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
- CheckIfNullTerminated(TStringBuf{it->Data(), it->Length()});
- UNIT_ASSERT_VALUES_EQUAL(0, it->Length());
- ++tokensCount;
- }
- UNIT_ASSERT_VALUES_EQUAL(dataSize, tokensCount);
- }
-
- Y_UNIT_TEST(FirstTokenHasSizeOfTheBufferTest) {
- const char data[] = "xxxxx\nxx";
- const auto dataSize = Y_ARRAY_SIZE(data) - 1;
+ return true;
+ }
+ };
+
+ const char data[] = "1234567890-=!@#$%^&*()_+QWERTYUIOP{}qwertyuiop[]ASDFGHJKL:";
+ const auto dataSize = Y_ARRAY_SIZE(data) - 1;
+ auto&& input = TMemoryInput{data, dataSize};
+ auto&& tokenizer = TStreamTokenizer<TAlwaysTrue>{&input};
+ auto tokensCount = size_t{};
+ for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
+ CheckIfNullTerminated(TStringBuf{it->Data(), it->Length()});
+ UNIT_ASSERT_VALUES_EQUAL(0, it->Length());
+ ++tokensCount;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(dataSize, tokensCount);
+ }
+
+ Y_UNIT_TEST(FirstTokenHasSizeOfTheBufferTest) {
+ const char data[] = "xxxxx\nxx";
+ const auto dataSize = Y_ARRAY_SIZE(data) - 1;
const TStringBuf tokens[] = {TStringBuf("xxxxx"), TStringBuf("xx")};
- const auto tokensSize = Y_ARRAY_SIZE(tokens);
- auto&& input = TMemoryInput{data, dataSize};
- auto&& tokenizer = TStreamTokenizer<TEol>{&input, TEol{}, tokens[0].size()};
- auto tokensCount = size_t{};
- for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
- const auto token = TStringBuf{it->Data(), it->Length()};
- CheckIfNullTerminated(token);
- UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
- ++tokensCount;
- }
- UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
- }
-
- Y_UNIT_TEST(OnlyTokenHasSizeOfTheBufferTest) {
- const char data[] = "xxxxx";
- const auto dataSize = Y_ARRAY_SIZE(data) - 1;
- auto&& input = TMemoryInput{data, dataSize};
- auto&& tokenizer = TStreamTokenizer<TEol>{&input, TEol{}, dataSize};
- auto tokensCount = size_t{};
- for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
- const auto token = TStringBuf{it->Data(), it->Length()};
- CheckIfNullTerminated(token);
- UNIT_ASSERT_VALUES_EQUAL(data, token);
- ++tokensCount;
- }
- UNIT_ASSERT_VALUES_EQUAL(1, tokensCount);
- }
-
- Y_UNIT_TEST(BufferSizeInitialSizeSmallerThanTokenTest) {
- const char data[] = "xxxxx\nxx";
- const auto dataSize = Y_ARRAY_SIZE(data) - 1;
+ const auto tokensSize = Y_ARRAY_SIZE(tokens);
+ auto&& input = TMemoryInput{data, dataSize};
+ auto&& tokenizer = TStreamTokenizer<TEol>{&input, TEol{}, tokens[0].size()};
+ auto tokensCount = size_t{};
+ for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
+ const auto token = TStringBuf{it->Data(), it->Length()};
+ CheckIfNullTerminated(token);
+ UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
+ ++tokensCount;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
+ }
+
+ Y_UNIT_TEST(OnlyTokenHasSizeOfTheBufferTest) {
+ const char data[] = "xxxxx";
+ const auto dataSize = Y_ARRAY_SIZE(data) - 1;
+ auto&& input = TMemoryInput{data, dataSize};
+ auto&& tokenizer = TStreamTokenizer<TEol>{&input, TEol{}, dataSize};
+ auto tokensCount = size_t{};
+ for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
+ const auto token = TStringBuf{it->Data(), it->Length()};
+ CheckIfNullTerminated(token);
+ UNIT_ASSERT_VALUES_EQUAL(data, token);
+ ++tokensCount;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(1, tokensCount);
+ }
+
+ Y_UNIT_TEST(BufferSizeInitialSizeSmallerThanTokenTest) {
+ const char data[] = "xxxxx\nxx";
+ const auto dataSize = Y_ARRAY_SIZE(data) - 1;
const TStringBuf tokens[] = {TStringBuf("xxxxx"), TStringBuf("xx")};
- const auto tokensSize = Y_ARRAY_SIZE(tokens);
- auto&& input = TMemoryInput{data, dataSize};
- auto&& tokenizer = TStreamTokenizer<TEol>{&input, TEol{}, 1};
- auto tokensCount = size_t{};
- for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
- const auto token = TStringBuf{it->Data(), it->Length()};
- CheckIfNullTerminated(token);
- UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
- ++tokensCount;
- }
- UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
- }
-
- Y_UNIT_TEST(RangeBasedForTest) {
- const char data[] = "abc\ndef\nxxxxxx";
- const auto dataSize = Y_ARRAY_SIZE(data) - 1;
+ const auto tokensSize = Y_ARRAY_SIZE(tokens);
+ auto&& input = TMemoryInput{data, dataSize};
+ auto&& tokenizer = TStreamTokenizer<TEol>{&input, TEol{}, 1};
+ auto tokensCount = size_t{};
+ for (auto it = tokenizer.begin(); tokenizer.end() != it; ++it) {
+ const auto token = TStringBuf{it->Data(), it->Length()};
+ CheckIfNullTerminated(token);
+ UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
+ ++tokensCount;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
+ }
+
+ Y_UNIT_TEST(RangeBasedForTest) {
+ const char data[] = "abc\ndef\nxxxxxx";
+ const auto dataSize = Y_ARRAY_SIZE(data) - 1;
const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")};
- const auto tokensSize = Y_ARRAY_SIZE(tokens);
- auto&& input = TMemoryInput{data, dataSize};
- auto&& tokenizer = TStreamTokenizer<TEol>{&input};
- auto tokensCount = size_t{};
- for (const auto& token : tokenizer) {
- UNIT_ASSERT(tokensCount < tokensSize);
- CheckIfNullTerminated(token);
- UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
- ++tokensCount;
- }
- UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
- }
-}
+ const auto tokensSize = Y_ARRAY_SIZE(tokens);
+ auto&& input = TMemoryInput{data, dataSize};
+ auto&& tokenizer = TStreamTokenizer<TEol>{&input};
+ auto tokensCount = size_t{};
+ for (const auto& token : tokenizer) {
+ UNIT_ASSERT(tokensCount < tokensSize);
+ CheckIfNullTerminated(token);
+ UNIT_ASSERT_VALUES_EQUAL(tokens[tokensCount], token);
+ ++tokensCount;
+ }
+ UNIT_ASSERT_VALUES_EQUAL(tokensSize, tokensCount);
+ }
+}
diff --git a/util/stream/trace.h b/util/stream/trace.h
index 9674dc7481..e74b6ecf3e 100644
--- a/util/stream/trace.h
+++ b/util/stream/trace.h
@@ -15,21 +15,21 @@ enum ETraceLevel: ui8 {
TRACE_VERBOSE = 7
};
-#if !defined(NDEBUG) && !defined(Y_ENABLE_TRACE)
+#if !defined(NDEBUG) && !defined(Y_ENABLE_TRACE)
#define Y_ENABLE_TRACE
#endif
-#ifdef Y_ENABLE_TRACE
+#ifdef Y_ENABLE_TRACE
/**
* Writes the given data into standard debug stream if current debug level set
* via `DBGOUT` environment variable permits it.
*
- * Does nothing in release builds unless `Y_ENABLE_TRACE` is defined.
+ * Does nothing in release builds unless `Y_ENABLE_TRACE` is defined.
*
* Example usage:
* @code
- * Y_DBGTRACE(DEBUG, "Advance from " << node1 << " to " << node2);
+ * Y_DBGTRACE(DEBUG, "Advance from " << node1 << " to " << node2);
* @endcode
*
* @param elevel Debug level of this trace command, e.g.
diff --git a/util/stream/walk.cpp b/util/stream/walk.cpp
index 0243939398..57dc9ab036 100644
--- a/util/stream/walk.cpp
+++ b/util/stream/walk.cpp
@@ -1,13 +1,13 @@
#include "walk.h"
#include <util/generic/string.h>
-
-void IWalkInput::DoUndo(size_t len) {
+
+void IWalkInput::DoUndo(size_t len) {
Len_ += len;
Buf_ = static_cast<const char*>(Buf_) - len;
}
-size_t IWalkInput::DoNext(const void** ptr, size_t len) {
+size_t IWalkInput::DoNext(const void** ptr, size_t len) {
if (!Len_) {
Len_ = DoUnboundedNext(&Buf_);
}
diff --git a/util/stream/walk.h b/util/stream/walk.h
index 36b50727e7..7e62cb44dc 100644
--- a/util/stream/walk.h
+++ b/util/stream/walk.h
@@ -7,10 +7,10 @@
*
* Derived classes must implement `DoUnboundedNext` method.
*/
-class IWalkInput: public IZeroCopyInputFastReadTo {
+class IWalkInput: public IZeroCopyInputFastReadTo {
public:
- IWalkInput()
- : Buf_(nullptr)
+ IWalkInput()
+ : Buf_(nullptr)
, Len_(0)
{
}
diff --git a/util/stream/walk_ut.cpp b/util/stream/walk_ut.cpp
index b5a8057b1b..e0a783799f 100644
--- a/util/stream/walk_ut.cpp
+++ b/util/stream/walk_ut.cpp
@@ -2,7 +2,7 @@
#include <library/cpp/testing/unittest/registar.h>
-class TStringListInput: public IWalkInput {
+class TStringListInput: public IWalkInput {
public:
TStringListInput(const TVector<TString>& data)
: Data_(data)
@@ -27,8 +27,8 @@ private:
size_t Index_;
};
-Y_UNIT_TEST_SUITE(TWalkTest) {
- Y_UNIT_TEST(ReadTo) {
+Y_UNIT_TEST_SUITE(TWalkTest) {
+ Y_UNIT_TEST(ReadTo) {
TVector<TString> data;
data.push_back("111a");
data.push_back("222b");
diff --git a/util/stream/zerocopy.cpp b/util/stream/zerocopy.cpp
index b8b378014c..dc2982ad55 100644
--- a/util/stream/zerocopy.cpp
+++ b/util/stream/zerocopy.cpp
@@ -1,9 +1,9 @@
#include "zerocopy.h"
#include "output.h"
-IZeroCopyInput::~IZeroCopyInput() = default;
+IZeroCopyInput::~IZeroCopyInput() = default;
-size_t IZeroCopyInput::DoRead(void* buf, size_t len) {
+size_t IZeroCopyInput::DoRead(void* buf, size_t len) {
const void* ptr;
size_t result = DoNext(&ptr, len);
@@ -14,7 +14,7 @@ size_t IZeroCopyInput::DoRead(void* buf, size_t len) {
return result;
}
-ui64 IZeroCopyInput::DoReadAll(IOutputStream& out) {
+ui64 IZeroCopyInput::DoReadAll(IOutputStream& out) {
ui64 result = 0;
const void* ptr;
@@ -26,15 +26,15 @@ ui64 IZeroCopyInput::DoReadAll(IOutputStream& out) {
return result;
}
-size_t IZeroCopyInput::DoSkip(size_t len) {
+size_t IZeroCopyInput::DoSkip(size_t len) {
const void* ptr;
return DoNext(&ptr, len);
}
-IZeroCopyInputFastReadTo::~IZeroCopyInputFastReadTo() = default;
+IZeroCopyInputFastReadTo::~IZeroCopyInputFastReadTo() = default;
-size_t IZeroCopyInputFastReadTo::DoReadTo(TString& st, char ch) {
+size_t IZeroCopyInputFastReadTo::DoReadTo(TString& st, char ch) {
const char* ptr;
size_t len = Next(&ptr);
if (!len) {
diff --git a/util/stream/zerocopy.h b/util/stream/zerocopy.h
index 9c99326d55..3315aa3a51 100644
--- a/util/stream/zerocopy.h
+++ b/util/stream/zerocopy.h
@@ -6,7 +6,7 @@
#include "input.h"
-class IOutputStream;
+class IOutputStream;
/**
* @addtogroup Streams
@@ -18,13 +18,13 @@ class IOutputStream;
*
* Derived classes must implement `DoNext` method.
*/
-class IZeroCopyInput: public IInputStream {
+class IZeroCopyInput: public IInputStream {
public:
- IZeroCopyInput() noexcept = default;
- ~IZeroCopyInput() override;
+ IZeroCopyInput() noexcept = default;
+ ~IZeroCopyInput() override;
- IZeroCopyInput(IZeroCopyInput&&) noexcept = default;
- IZeroCopyInput& operator=(IZeroCopyInput&&) noexcept = default;
+ IZeroCopyInput(IZeroCopyInput&&) noexcept = default;
+ IZeroCopyInput& operator=(IZeroCopyInput&&) noexcept = default;
/**
* Returns the next data chunk from this input stream.
@@ -39,7 +39,7 @@ public:
*/
template <class T>
inline size_t Next(T** ptr, size_t len) {
- Y_ASSERT(ptr);
+ Y_ASSERT(ptr);
return DoNext((const void**)ptr, len);
}
@@ -52,7 +52,7 @@ public:
protected:
size_t DoRead(void* buf, size_t len) override;
size_t DoSkip(size_t len) override;
- ui64 DoReadAll(IOutputStream& out) override;
+ ui64 DoReadAll(IOutputStream& out) override;
virtual size_t DoNext(const void** ptr, size_t len) = 0;
};
@@ -61,13 +61,13 @@ protected:
*
* Derived classes must implement `DoUndo` method.
*/
-class IZeroCopyInputFastReadTo: public IZeroCopyInput {
+class IZeroCopyInputFastReadTo: public IZeroCopyInput {
public:
- IZeroCopyInputFastReadTo() noexcept = default;
- ~IZeroCopyInputFastReadTo() override;
+ IZeroCopyInputFastReadTo() noexcept = default;
+ ~IZeroCopyInputFastReadTo() override;
- IZeroCopyInputFastReadTo(IZeroCopyInputFastReadTo&&) noexcept = default;
- IZeroCopyInputFastReadTo& operator=(IZeroCopyInputFastReadTo&&) noexcept = default;
+ IZeroCopyInputFastReadTo(IZeroCopyInputFastReadTo&&) noexcept = default;
+ IZeroCopyInputFastReadTo& operator=(IZeroCopyInputFastReadTo&&) noexcept = default;
protected:
size_t DoReadTo(TString& st, char ch) override;
diff --git a/util/stream/zlib.cpp b/util/stream/zlib.cpp
index 2893cc044b..60f4e9439f 100644
--- a/util/stream/zlib.cpp
+++ b/util/stream/zlib.cpp
@@ -29,7 +29,7 @@ namespace {
inline ~TZLibCommon() = default;
inline const char* GetErrMsg() const noexcept {
- return Z()->msg != nullptr ? Z()->msg : "unknown error";
+ return Z()->msg != nullptr ? Z()->msg : "unknown error";
}
inline z_stream* Z() const noexcept {
@@ -45,9 +45,9 @@ namespace {
}
struct TChunkedZeroCopyInput {
- inline TChunkedZeroCopyInput(IZeroCopyInput* in)
+ inline TChunkedZeroCopyInput(IZeroCopyInput* in)
: In(in)
- , Buf(nullptr)
+ , Buf(nullptr)
, Len(0)
{
}
@@ -72,7 +72,7 @@ namespace {
return true;
}
- IZeroCopyInput* In;
+ IZeroCopyInput* In;
const char* Buf;
size_t Len;
};
@@ -162,7 +162,7 @@ private:
};
namespace {
- class TDecompressStream: public IZeroCopyInput, public TZLibDecompress::TImpl, public TAdditionalStorage<TDecompressStream> {
+ class TDecompressStream: public IZeroCopyInput, public TZLibDecompress::TImpl, public TAdditionalStorage<TDecompressStream> {
public:
inline TDecompressStream(IInputStream* input, ZLib::StreamType type, TStringBuf dict)
: TZLibDecompress::TImpl(this, type, dict)
@@ -181,7 +181,7 @@ namespace {
}
private:
- IInputStream* Stream_;
+ IInputStream* Stream_;
};
using TZeroCopyDecompress = TZLibDecompress::TImpl;
@@ -314,7 +314,7 @@ private:
}
private:
- IOutputStream* Stream_;
+ IOutputStream* Stream_;
THolder<gz_header> GZHeader_;
};
diff --git a/util/stream/zlib.h b/util/stream/zlib.h
index 8abf255b53..e7de7c81b7 100644
--- a/util/stream/zlib.h
+++ b/util/stream/zlib.h
@@ -1,6 +1,6 @@
#pragma once
-#include "fwd.h"
+#include "fwd.h"
#include "input.h"
#include "output.h"
#include "buffered.h"
@@ -45,7 +45,7 @@ namespace ZLib {
* benchmark). For fast buffered ZLib stream reading use `TBufferedZLibDecompress`
* aka `TZDecompress`.
*/
-class TZLibDecompress: public IInputStream {
+class TZLibDecompress: public IInputStream {
public:
TZLibDecompress(IZeroCopyInput* input, ZLib::StreamType type = ZLib::Auto, TStringBuf dict = {});
TZLibDecompress(IInputStream* input, ZLib::StreamType type = ZLib::Auto, size_t buflen = ZLib::ZLIB_BUF_LEN,
@@ -56,7 +56,7 @@ public:
*
* If multiple streams are allowed, their decompressed content will be concatenated.
* If multiple streams are disabled, then only first stream is decompressed. After that end
- * of IInputStream will have happen, i.e. method Read() will return 0.
+ * of IInputStream will have happen, i.e. method Read() will return 0.
*
* @param allowMultipleStreams - flag to allow (true) or disable (false) multiple streams.
*/
@@ -75,10 +75,10 @@ public:
/**
* Non-buffered ZLib compressing stream.
*/
-class TZLibCompress: public IOutputStream {
+class TZLibCompress: public IOutputStream {
public:
struct TParams {
- inline TParams(IOutputStream* out)
+ inline TParams(IOutputStream* out)
: Out(out)
, Type(ZLib::ZLib)
, CompressionLevel(6)
@@ -104,13 +104,13 @@ public:
return *this;
}
- inline TParams& SetDict(const TStringBuf dict) noexcept {
+ inline TParams& SetDict(const TStringBuf dict) noexcept {
Dict = dict;
return *this;
}
- IOutputStream* Out;
+ IOutputStream* Out;
ZLib::StreamType Type;
size_t CompressionLevel;
size_t BufLen;
@@ -121,15 +121,15 @@ public:
Init(params);
}
- inline TZLibCompress(IOutputStream* out, ZLib::StreamType type) {
+ inline TZLibCompress(IOutputStream* out, ZLib::StreamType type) {
Init(TParams(out).SetType(type));
}
- inline TZLibCompress(IOutputStream* out, ZLib::StreamType type, size_t compression_level) {
+ inline TZLibCompress(IOutputStream* out, ZLib::StreamType type, size_t compression_level) {
Init(TParams(out).SetType(type).SetCompressionLevel(compression_level));
}
- inline TZLibCompress(IOutputStream* out, ZLib::StreamType type, size_t compression_level, size_t buflen) {
+ inline TZLibCompress(IOutputStream* out, ZLib::StreamType type, size_t compression_level, size_t buflen) {
Init(TParams(out).SetType(type).SetCompressionLevel(compression_level).SetBufLen(buflen));
}
diff --git a/util/stream/zlib_ut.cpp b/util/stream/zlib_ut.cpp
index b145da317f..2290b4a9de 100644
--- a/util/stream/zlib_ut.cpp
+++ b/util/stream/zlib_ut.cpp
@@ -51,11 +51,11 @@ private:
int Limit_;
};
-Y_UNIT_TEST_SUITE(TZLibTest) {
+Y_UNIT_TEST_SUITE(TZLibTest) {
static const TString DATA = "8s7d5vc6s5vc67sa4c65ascx6asd4xcv76adsfxv76s";
static const TString DATA2 = "cn8wk2bd9vb3vdfif83g1ks94bfiovtwv";
- Y_UNIT_TEST(Compress) {
+ Y_UNIT_TEST(Compress) {
TUnbufferedFileOutput o(ZDATA);
TZLibCompress c(&o, ZLib::ZLib);
@@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
o.Finish();
}
- Y_UNIT_TEST(Decompress) {
+ Y_UNIT_TEST(Decompress) {
TTempFile tmpFile(ZDATA);
{
@@ -90,7 +90,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
}
}
- Y_UNIT_TEST(DecompressTwoStreams) {
+ Y_UNIT_TEST(DecompressTwoStreams) {
// Check that Decompress(Compress(X) + Compress(Y)) == X + Y
TTempFile tmpFile(ZDATA);
{
@@ -126,7 +126,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
TVector<char>().swap(buf);
}
- Y_UNIT_TEST(DecompressFirstOfTwoStreams) {
+ Y_UNIT_TEST(DecompressFirstOfTwoStreams) {
// Check that Decompress(Compress(X) + Compress(Y)) == X when single stream is allowed
TTempFile tmpFile(ZDATA);
{
diff --git a/util/string/ascii.h b/util/string/ascii.h
index 9c2c090df1..10344384d3 100644
--- a/util/string/ascii.h
+++ b/util/string/ascii.h
@@ -60,7 +60,7 @@ namespace NPrivate {
#endif
}
-constexpr bool IsAscii(const int c) noexcept {
+constexpr bool IsAscii(const int c) noexcept {
return !(c & ~0x7f);
}
diff --git a/util/string/ascii_ut.cpp b/util/string/ascii_ut.cpp
index 94fea01a0e..89069fee50 100644
--- a/util/string/ascii_ut.cpp
+++ b/util/string/ascii_ut.cpp
@@ -3,8 +3,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TAsciiTest) {
- Y_UNIT_TEST(TestAscii) {
+Y_UNIT_TEST_SUITE(TAsciiTest) {
+ Y_UNIT_TEST(TestAscii) {
UNIT_ASSERT(IsAsciiDigit('3'));
UNIT_ASSERT(!IsAsciiDigit('x'));
@@ -38,7 +38,7 @@ Y_UNIT_TEST_SUITE(TAsciiTest) {
}
}
- Y_UNIT_TEST(Test1) {
+ Y_UNIT_TEST(Test1) {
for (int i = 128; i < 1000; ++i) {
UNIT_ASSERT(!IsAsciiHex(i));
UNIT_ASSERT(!IsAsciiSpace(i));
@@ -62,7 +62,7 @@ Y_UNIT_TEST_SUITE(TAsciiTest) {
}
}
- Y_UNIT_TEST(CompareTest) {
+ Y_UNIT_TEST(CompareTest) {
UNIT_ASSERT(AsciiEqualsIgnoreCase("qqq", "qQq"));
UNIT_ASSERT(AsciiEqualsIgnoreCase("qqq", TStringBuf("qQq")));
TString qq = "qq";
diff --git a/util/string/benchmark/float_to_string/main.cpp b/util/string/benchmark/float_to_string/main.cpp
index c15b6009ad..1c7c0684a3 100644
--- a/util/string/benchmark/float_to_string/main.cpp
+++ b/util/string/benchmark/float_to_string/main.cpp
@@ -1,253 +1,253 @@
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/generic/singleton.h>
-#include <util/generic/vector.h>
-#include <util/generic/xrange.h>
-#include <util/generic/ymath.h>
-#include <util/random/fast.h>
-#include <util/string/cast.h>
-#include <util/string/printf.h>
-
-#include <limits>
-
-#include <cmath>
-
-/* Please be careful before making any decisions based on this benchmark.
- *
- * Only `Sprintf("%.<decimals>f", x)` and `FloatToString(x, PREC_POINT_DIGITS, decimals` produce
- * equal results in general case. However, results for cases when x \in [0, 1) must be equal for
- * both `Sprintf` and `FloatToString`.
- *
- * Read more about formatting in STL [1, 2] and Yandex Util formatting [3]
- *
- * [1] http://www.cplusplus.com/reference/cstdio/printf/
- * [2] http://en.cppreference.com/w/c/io/fprintf
- * [3] https://a.yandex-team.ru/arc/trunk/arcadia/util/string/cast.h?rev=2432660#L29
- */
-
-namespace {
- template <typename T>
- struct TExample {
- T Value{};
- int DigitsCount{};
- };
-
- template <typename T, size_t N>
- struct TExamplesHolder {
+
+#include <util/generic/singleton.h>
+#include <util/generic/vector.h>
+#include <util/generic/xrange.h>
+#include <util/generic/ymath.h>
+#include <util/random/fast.h>
+#include <util/string/cast.h>
+#include <util/string/printf.h>
+
+#include <limits>
+
+#include <cmath>
+
+/* Please be careful before making any decisions based on this benchmark.
+ *
+ * Only `Sprintf("%.<decimals>f", x)` and `FloatToString(x, PREC_POINT_DIGITS, decimals` produce
+ * equal results in general case. However, results for cases when x \in [0, 1) must be equal for
+ * both `Sprintf` and `FloatToString`.
+ *
+ * Read more about formatting in STL [1, 2] and Yandex Util formatting [3]
+ *
+ * [1] http://www.cplusplus.com/reference/cstdio/printf/
+ * [2] http://en.cppreference.com/w/c/io/fprintf
+ * [3] https://a.yandex-team.ru/arc/trunk/arcadia/util/string/cast.h?rev=2432660#L29
+ */
+
+namespace {
+ template <typename T>
+ struct TExample {
+ T Value{};
+ int DigitsCount{};
+ };
+
+ template <typename T, size_t N>
+ struct TExamplesHolder {
TVector<TExample<T>> Examples;
-
- TExamplesHolder()
+
+ TExamplesHolder()
: Examples(N)
{
- TFastRng<ui64> prng{N * sizeof(T) * 42};
- for (auto& x : Examples) {
- x.Value = prng.GenRandReal4() + prng.Uniform(Max<ui16>());
- x.DigitsCount = prng.Uniform(std::numeric_limits<T>::max_digits10 + 1);
- }
- }
- };
-
- template <typename T, size_t N>
- struct TNearZeroExamplesHolder {
+ TFastRng<ui64> prng{N * sizeof(T) * 42};
+ for (auto& x : Examples) {
+ x.Value = prng.GenRandReal4() + prng.Uniform(Max<ui16>());
+ x.DigitsCount = prng.Uniform(std::numeric_limits<T>::max_digits10 + 1);
+ }
+ }
+ };
+
+ template <typename T, size_t N>
+ struct TNearZeroExamplesHolder {
TVector<TExample<T>> Examples;
-
- TNearZeroExamplesHolder()
+
+ TNearZeroExamplesHolder()
: Examples(N)
{
- TFastRng<ui64> prng{N * sizeof(T) * 42};
- for (auto& x : Examples) {
- x.Value = prng.GenRandReal4();
- x.DigitsCount = prng.Uniform(std::numeric_limits<T>::max_digits10 + 1);
- }
- }
- };
-}
-
-static const char* FORMAT_FIXED[] = {
- "%.0f",
- "%.1f",
- "%.2f",
- "%.3f",
- "%.4f",
- "%.5f",
- "%.6f",
- "%.7f",
- "%.8f",
- "%.9f",
- "%.10f",
- "%.11f",
- "%.12f",
- "%.13f",
- "%.14f",
- "%.15f",
- "%.16f",
- "%.17f",
-};
-
-static const char* FORMAT_SIGNIFICANT[] = {
- "%.0g",
- "%.1g",
- "%.2g",
- "%.3g",
- "%.4g",
- "%.5g",
- "%.6g",
- "%.7g",
- "%.8g",
- "%.9g",
- "%.10g",
- "%.11g",
- "%.12g",
- "%.13g",
- "%.14g",
- "%.15g",
- "%.16g",
- "%.17g",
-};
-
-#define DEFINE_BENCHMARK(type, count) \
- Y_CPU_BENCHMARK(SprintfAuto_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- /* this is in fact equal to Sprintf("%.6f", e.Value) and that is why it is faster */ \
- /* than FloatToString(e.Value) */ \
- Y_DO_NOT_OPTIMIZE_AWAY(Sprintf("%f", e.Value)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(FloatToStringAuto_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(SprintfFixed_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_FIXED[e.DigitsCount], e.Value)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(FloatToStringFixed_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_NDIGITS, e.DigitsCount)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(SprintfSignificant_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_SIGNIFICANT[e.DigitsCount], e.Value)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(FloatToStringSignificant_##type##_##count, iface) { \
- const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_POINT_DIGITS, e.DigitsCount)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(NearZeroSprintfAuto_##type##_##count, iface) { \
- const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- /* this is in fact equal to Sprintf("%.6f", e.Value) and that is why it is faster */ \
- /* than FloatToString(e.Value) */ \
- Y_DO_NOT_OPTIMIZE_AWAY(Sprintf("%f", e.Value)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(NearZeroFloatToStringAuto_##type##_##count, iface) { \
- const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(NearZeroSprintfFixed_##type##_##count, iface) { \
- const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_FIXED[e.DigitsCount], e.Value)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(NearZeroFloatToStringFixed_##type##_##count, iface) { \
- const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_NDIGITS, e.DigitsCount)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(NearZeroSprintfSignificant_##type##_##count, iface) { \
- const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_SIGNIFICANT[e.DigitsCount], e.Value)); \
- } \
- } \
- } \
- \
- Y_CPU_BENCHMARK(NearZeroFloatToStringSignificant_##type##_##count, iface) { \
- const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- for (const auto e : examples) { \
- Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_POINT_DIGITS, e.DigitsCount)); \
- } \
- } \
- }
-
-DEFINE_BENCHMARK(float, 1);
-DEFINE_BENCHMARK(float, 2);
-DEFINE_BENCHMARK(float, 4);
-DEFINE_BENCHMARK(float, 8);
-DEFINE_BENCHMARK(float, 16);
-DEFINE_BENCHMARK(float, 32);
-DEFINE_BENCHMARK(float, 64);
-DEFINE_BENCHMARK(float, 128);
-DEFINE_BENCHMARK(float, 256);
-
-DEFINE_BENCHMARK(double, 1);
-DEFINE_BENCHMARK(double, 2);
-DEFINE_BENCHMARK(double, 4);
-DEFINE_BENCHMARK(double, 8);
-DEFINE_BENCHMARK(double, 16);
-DEFINE_BENCHMARK(double, 32);
-DEFINE_BENCHMARK(double, 64);
-DEFINE_BENCHMARK(double, 128);
-DEFINE_BENCHMARK(double, 256);
-
-#undef DEFINE_BENCHMARK
+ TFastRng<ui64> prng{N * sizeof(T) * 42};
+ for (auto& x : Examples) {
+ x.Value = prng.GenRandReal4();
+ x.DigitsCount = prng.Uniform(std::numeric_limits<T>::max_digits10 + 1);
+ }
+ }
+ };
+}
+
+static const char* FORMAT_FIXED[] = {
+ "%.0f",
+ "%.1f",
+ "%.2f",
+ "%.3f",
+ "%.4f",
+ "%.5f",
+ "%.6f",
+ "%.7f",
+ "%.8f",
+ "%.9f",
+ "%.10f",
+ "%.11f",
+ "%.12f",
+ "%.13f",
+ "%.14f",
+ "%.15f",
+ "%.16f",
+ "%.17f",
+};
+
+static const char* FORMAT_SIGNIFICANT[] = {
+ "%.0g",
+ "%.1g",
+ "%.2g",
+ "%.3g",
+ "%.4g",
+ "%.5g",
+ "%.6g",
+ "%.7g",
+ "%.8g",
+ "%.9g",
+ "%.10g",
+ "%.11g",
+ "%.12g",
+ "%.13g",
+ "%.14g",
+ "%.15g",
+ "%.16g",
+ "%.17g",
+};
+
+#define DEFINE_BENCHMARK(type, count) \
+ Y_CPU_BENCHMARK(SprintfAuto_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ /* this is in fact equal to Sprintf("%.6f", e.Value) and that is why it is faster */ \
+ /* than FloatToString(e.Value) */ \
+ Y_DO_NOT_OPTIMIZE_AWAY(Sprintf("%f", e.Value)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(FloatToStringAuto_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(SprintfFixed_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_FIXED[e.DigitsCount], e.Value)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(FloatToStringFixed_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_NDIGITS, e.DigitsCount)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(SprintfSignificant_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_SIGNIFICANT[e.DigitsCount], e.Value)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(FloatToStringSignificant_##type##_##count, iface) { \
+ const auto& examples = Default<TExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_POINT_DIGITS, e.DigitsCount)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(NearZeroSprintfAuto_##type##_##count, iface) { \
+ const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ /* this is in fact equal to Sprintf("%.6f", e.Value) and that is why it is faster */ \
+ /* than FloatToString(e.Value) */ \
+ Y_DO_NOT_OPTIMIZE_AWAY(Sprintf("%f", e.Value)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(NearZeroFloatToStringAuto_##type##_##count, iface) { \
+ const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(NearZeroSprintfFixed_##type##_##count, iface) { \
+ const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_FIXED[e.DigitsCount], e.Value)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(NearZeroFloatToStringFixed_##type##_##count, iface) { \
+ const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_NDIGITS, e.DigitsCount)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(NearZeroSprintfSignificant_##type##_##count, iface) { \
+ const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(Sprintf(FORMAT_SIGNIFICANT[e.DigitsCount], e.Value)); \
+ } \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(NearZeroFloatToStringSignificant_##type##_##count, iface) { \
+ const auto& examples = Default<TNearZeroExamplesHolder<type, count>>().Examples; \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ for (const auto e : examples) { \
+ Y_DO_NOT_OPTIMIZE_AWAY(FloatToString(e.Value, PREC_POINT_DIGITS, e.DigitsCount)); \
+ } \
+ } \
+ }
+
+DEFINE_BENCHMARK(float, 1);
+DEFINE_BENCHMARK(float, 2);
+DEFINE_BENCHMARK(float, 4);
+DEFINE_BENCHMARK(float, 8);
+DEFINE_BENCHMARK(float, 16);
+DEFINE_BENCHMARK(float, 32);
+DEFINE_BENCHMARK(float, 64);
+DEFINE_BENCHMARK(float, 128);
+DEFINE_BENCHMARK(float, 256);
+
+DEFINE_BENCHMARK(double, 1);
+DEFINE_BENCHMARK(double, 2);
+DEFINE_BENCHMARK(double, 4);
+DEFINE_BENCHMARK(double, 8);
+DEFINE_BENCHMARK(double, 16);
+DEFINE_BENCHMARK(double, 32);
+DEFINE_BENCHMARK(double, 64);
+DEFINE_BENCHMARK(double, 128);
+DEFINE_BENCHMARK(double, 256);
+
+#undef DEFINE_BENCHMARK
diff --git a/util/string/benchmark/float_to_string/metrics/main.py b/util/string/benchmark/float_to_string/metrics/main.py
index fdcfd71b0b..e9d4b7ac1d 100644
--- a/util/string/benchmark/float_to_string/metrics/main.py
+++ b/util/string/benchmark/float_to_string/metrics/main.py
@@ -1,5 +1,5 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
metrics.set_benchmark(yc.execute_benchmark('util/string/benchmark/float_to_string/float_to_string', threads=8))
diff --git a/util/string/benchmark/float_to_string/metrics/ya.make b/util/string/benchmark/float_to_string/metrics/ya.make
index 3081301d1d..4b8c4cc07d 100644
--- a/util/string/benchmark/float_to_string/metrics/ya.make
+++ b/util/string/benchmark/float_to_string/metrics/ya.make
@@ -1,21 +1,21 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/string/benchmark/float_to_string)
-
-END()
+
+END()
diff --git a/util/string/benchmark/float_to_string/ya.make b/util/string/benchmark/float_to_string/ya.make
index 30955f3189..8136ad34f0 100644
--- a/util/string/benchmark/float_to_string/ya.make
+++ b/util/string/benchmark/float_to_string/ya.make
@@ -1,12 +1,12 @@
OWNER(yazevnul)
-
+
Y_BENCHMARK()
-
+
# to minimize allocations overhead
ALLOCATOR(B)
-
-SRCS(
- main.cpp
-)
-
-END()
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/string/benchmark/subst_global/main.cpp b/util/string/benchmark/subst_global/main.cpp
index c9b14a5211..e0decfa042 100644
--- a/util/string/benchmark/subst_global/main.cpp
+++ b/util/string/benchmark/subst_global/main.cpp
@@ -1,203 +1,203 @@
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/generic/cast.h>
-#include <util/generic/singleton.h>
+
+#include <util/generic/cast.h>
+#include <util/generic/singleton.h>
#include <util/generic/string.h>
-#include <util/generic/xrange.h>
-#include <util/random/fast.h>
-#include <util/string/cast.h>
-#include <util/string/subst.h>
-
-namespace {
- template <size_t N, char What, char With>
- struct TNoMatches {
- enum : char {
- WHAT = What,
- WITH = With
- };
+#include <util/generic/xrange.h>
+#include <util/random/fast.h>
+#include <util/string/cast.h>
+#include <util/string/subst.h>
+
+namespace {
+ template <size_t N, char What, char With>
+ struct TNoMatches {
+ enum : char {
+ WHAT = What,
+ WITH = With
+ };
TString Str;
-
- TNoMatches() {
- for (const auto dummy : xrange(N)) {
- Y_UNUSED(dummy);
- Str += WHAT + 1;
- }
- }
- };
-
- template <size_t N, char What, char With>
- struct TOneMatchInTheBeginning {
- enum : char {
- WHAT = What,
- WITH = With
- };
+
+ TNoMatches() {
+ for (const auto dummy : xrange(N)) {
+ Y_UNUSED(dummy);
+ Str += WHAT + 1;
+ }
+ }
+ };
+
+ template <size_t N, char What, char With>
+ struct TOneMatchInTheBeginning {
+ enum : char {
+ WHAT = What,
+ WITH = With
+ };
TString Str;
-
- TOneMatchInTheBeginning() {
- if (!N) {
- return;
- }
-
- Str += WHAT;
- if (N > 1) {
- for (const auto dummy : xrange(N - 1)) {
- Y_UNUSED(dummy);
- Str += WHAT + 1;
- }
- }
- }
- };
-
- template <size_t N, char What, char With>
- struct TOneMatchInTheEnd {
- enum : char {
- WHAT = What,
- WITH = With
- };
+
+ TOneMatchInTheBeginning() {
+ if (!N) {
+ return;
+ }
+
+ Str += WHAT;
+ if (N > 1) {
+ for (const auto dummy : xrange(N - 1)) {
+ Y_UNUSED(dummy);
+ Str += WHAT + 1;
+ }
+ }
+ }
+ };
+
+ template <size_t N, char What, char With>
+ struct TOneMatchInTheEnd {
+ enum : char {
+ WHAT = What,
+ WITH = With
+ };
TString Str;
-
- TOneMatchInTheEnd() {
- if (!N) {
- return;
- }
-
- if (N > 1) {
- for (const auto dummy : xrange(N - 1)) {
- Y_UNUSED(dummy);
- Str += WHAT + 1;
- }
- }
- Str += WHAT;
- }
- };
-
- template <size_t N, char What, char With>
- struct TOneMatchInTheMiddle {
- enum : char {
- WHAT = What,
- WITH = With
- };
+
+ TOneMatchInTheEnd() {
+ if (!N) {
+ return;
+ }
+
+ if (N > 1) {
+ for (const auto dummy : xrange(N - 1)) {
+ Y_UNUSED(dummy);
+ Str += WHAT + 1;
+ }
+ }
+ Str += WHAT;
+ }
+ };
+
+ template <size_t N, char What, char With>
+ struct TOneMatchInTheMiddle {
+ enum : char {
+ WHAT = What,
+ WITH = With
+ };
TString Str;
-
- TOneMatchInTheMiddle() {
- if (!N) {
- return;
- }
-
- for (size_t i = 0; i < N / 2; ++i) {
- Str += WHAT + 1;
- }
- Str += WHAT;
- for (; Str.size() < N;) {
- Str += WHAT + 1;
- }
- }
- };
-
- template <size_t N, char What, char With>
- struct TFirstHalfMatches {
- enum : char {
- WHAT = What,
- WITH = With
- };
+
+ TOneMatchInTheMiddle() {
+ if (!N) {
+ return;
+ }
+
+ for (size_t i = 0; i < N / 2; ++i) {
+ Str += WHAT + 1;
+ }
+ Str += WHAT;
+ for (; Str.size() < N;) {
+ Str += WHAT + 1;
+ }
+ }
+ };
+
+ template <size_t N, char What, char With>
+ struct TFirstHalfMatches {
+ enum : char {
+ WHAT = What,
+ WITH = With
+ };
TString Str;
-
- TFirstHalfMatches() {
- for (size_t i = 0; i < N / 2; ++i) {
- Str += WHAT;
- }
- for (; Str.size() != N;) {
- Str += WHAT + 1;
- }
- }
- };
-
- template <size_t N, char What, char With>
- struct TSecondHalfMatches {
- enum : char {
- WHAT = What,
- WITH = With
- };
+
+ TFirstHalfMatches() {
+ for (size_t i = 0; i < N / 2; ++i) {
+ Str += WHAT;
+ }
+ for (; Str.size() != N;) {
+ Str += WHAT + 1;
+ }
+ }
+ };
+
+ template <size_t N, char What, char With>
+ struct TSecondHalfMatches {
+ enum : char {
+ WHAT = What,
+ WITH = With
+ };
TString Str;
-
- TSecondHalfMatches() {
- for (size_t i = 0; i < N / 2; ++i) {
- Str += WHAT + 1;
- }
- for (; Str.size() != N;) {
- Str += WHAT;
- }
- }
- };
-
- template <size_t N, size_t K, char What, char With>
- struct TEveryKth {
- enum : char {
- WHAT = What,
- WITH = With
- };
+
+ TSecondHalfMatches() {
+ for (size_t i = 0; i < N / 2; ++i) {
+ Str += WHAT + 1;
+ }
+ for (; Str.size() != N;) {
+ Str += WHAT;
+ }
+ }
+ };
+
+ template <size_t N, size_t K, char What, char With>
+ struct TEveryKth {
+ enum : char {
+ WHAT = What,
+ WITH = With
+ };
TString Str;
-
- TEveryKth() {
- TFastRng<ui64> prng{N * K * 101};
- for (size_t i = 0; i < N; ++i) {
- Str += (prng() % K) ? (WHAT + 1) : WHAT;
- }
- }
- };
-}
-
-#define DEFINE_BENCHMARK(type, N) \
- Y_CPU_BENCHMARK(type##_##N, i) { \
- using D = T##type<N, 'a', 'z'>; \
- const auto& str = Default<D>().Str; \
- for (const auto dummy : xrange(i.Iterations())) { \
- Y_UNUSED(dummy); \
- auto s = str; \
+
+ TEveryKth() {
+ TFastRng<ui64> prng{N * K * 101};
+ for (size_t i = 0; i < N; ++i) {
+ Str += (prng() % K) ? (WHAT + 1) : WHAT;
+ }
+ }
+ };
+}
+
+#define DEFINE_BENCHMARK(type, N) \
+ Y_CPU_BENCHMARK(type##_##N, i) { \
+ using D = T##type<N, 'a', 'z'>; \
+ const auto& str = Default<D>().Str; \
+ for (const auto dummy : xrange(i.Iterations())) { \
+ Y_UNUSED(dummy); \
+ auto s = str; \
NBench::Escape(s.data()); \
- Y_DO_NOT_OPTIMIZE_AWAY(SubstGlobal(s, ToUnderlying(D::WHAT), ToUnderlying(D::WITH))); \
- NBench::Clobber(); \
- } \
- }
-
-#define DEFINE_RNG_BENCHMARK(N, K) \
- Y_CPU_BENCHMARK(Random_##N##_##K, i) { \
- using D = TEveryKth<N, K, 'a', 'z'>; \
- const auto& str = Default<D>().Str; \
- for (const auto dummy : xrange(i.Iterations())) { \
- Y_UNUSED(dummy); \
- auto s = str; \
+ Y_DO_NOT_OPTIMIZE_AWAY(SubstGlobal(s, ToUnderlying(D::WHAT), ToUnderlying(D::WITH))); \
+ NBench::Clobber(); \
+ } \
+ }
+
+#define DEFINE_RNG_BENCHMARK(N, K) \
+ Y_CPU_BENCHMARK(Random_##N##_##K, i) { \
+ using D = TEveryKth<N, K, 'a', 'z'>; \
+ const auto& str = Default<D>().Str; \
+ for (const auto dummy : xrange(i.Iterations())) { \
+ Y_UNUSED(dummy); \
+ auto s = str; \
NBench::Escape(s.data()); \
- Y_DO_NOT_OPTIMIZE_AWAY(SubstGlobal(s, ToUnderlying(D::WHAT), ToUnderlying(D::WITH))); \
- NBench::Clobber(); \
- } \
- }
-
-DEFINE_BENCHMARK(NoMatches, 0)
-DEFINE_BENCHMARK(NoMatches, 1)
-DEFINE_BENCHMARK(NoMatches, 128)
-DEFINE_BENCHMARK(NoMatches, 4096)
-DEFINE_BENCHMARK(OneMatchInTheBeginning, 1)
-DEFINE_BENCHMARK(OneMatchInTheBeginning, 16)
-DEFINE_BENCHMARK(OneMatchInTheBeginning, 128)
-DEFINE_BENCHMARK(OneMatchInTheBeginning, 4096)
-DEFINE_BENCHMARK(OneMatchInTheEnd, 16)
-DEFINE_BENCHMARK(OneMatchInTheEnd, 128)
-DEFINE_BENCHMARK(OneMatchInTheEnd, 4096)
-DEFINE_BENCHMARK(OneMatchInTheMiddle, 16)
-DEFINE_BENCHMARK(OneMatchInTheMiddle, 128)
-DEFINE_BENCHMARK(OneMatchInTheMiddle, 4096)
-DEFINE_BENCHMARK(FirstHalfMatches, 16)
-DEFINE_BENCHMARK(FirstHalfMatches, 128)
-DEFINE_BENCHMARK(FirstHalfMatches, 4096)
-DEFINE_BENCHMARK(SecondHalfMatches, 16)
-DEFINE_BENCHMARK(SecondHalfMatches, 128)
-DEFINE_BENCHMARK(SecondHalfMatches, 4096)
-
-DEFINE_RNG_BENCHMARK(4096, 1)
-DEFINE_RNG_BENCHMARK(4096, 2)
-DEFINE_RNG_BENCHMARK(4096, 3)
-DEFINE_RNG_BENCHMARK(4096, 4)
-DEFINE_RNG_BENCHMARK(4096, 10)
-DEFINE_RNG_BENCHMARK(4096, 32)
-DEFINE_RNG_BENCHMARK(4096, 100)
+ Y_DO_NOT_OPTIMIZE_AWAY(SubstGlobal(s, ToUnderlying(D::WHAT), ToUnderlying(D::WITH))); \
+ NBench::Clobber(); \
+ } \
+ }
+
+DEFINE_BENCHMARK(NoMatches, 0)
+DEFINE_BENCHMARK(NoMatches, 1)
+DEFINE_BENCHMARK(NoMatches, 128)
+DEFINE_BENCHMARK(NoMatches, 4096)
+DEFINE_BENCHMARK(OneMatchInTheBeginning, 1)
+DEFINE_BENCHMARK(OneMatchInTheBeginning, 16)
+DEFINE_BENCHMARK(OneMatchInTheBeginning, 128)
+DEFINE_BENCHMARK(OneMatchInTheBeginning, 4096)
+DEFINE_BENCHMARK(OneMatchInTheEnd, 16)
+DEFINE_BENCHMARK(OneMatchInTheEnd, 128)
+DEFINE_BENCHMARK(OneMatchInTheEnd, 4096)
+DEFINE_BENCHMARK(OneMatchInTheMiddle, 16)
+DEFINE_BENCHMARK(OneMatchInTheMiddle, 128)
+DEFINE_BENCHMARK(OneMatchInTheMiddle, 4096)
+DEFINE_BENCHMARK(FirstHalfMatches, 16)
+DEFINE_BENCHMARK(FirstHalfMatches, 128)
+DEFINE_BENCHMARK(FirstHalfMatches, 4096)
+DEFINE_BENCHMARK(SecondHalfMatches, 16)
+DEFINE_BENCHMARK(SecondHalfMatches, 128)
+DEFINE_BENCHMARK(SecondHalfMatches, 4096)
+
+DEFINE_RNG_BENCHMARK(4096, 1)
+DEFINE_RNG_BENCHMARK(4096, 2)
+DEFINE_RNG_BENCHMARK(4096, 3)
+DEFINE_RNG_BENCHMARK(4096, 4)
+DEFINE_RNG_BENCHMARK(4096, 10)
+DEFINE_RNG_BENCHMARK(4096, 32)
+DEFINE_RNG_BENCHMARK(4096, 100)
diff --git a/util/string/benchmark/subst_global/metrics/main.py b/util/string/benchmark/subst_global/metrics/main.py
index 8aa0501351..62f2f3d76d 100644
--- a/util/string/benchmark/subst_global/metrics/main.py
+++ b/util/string/benchmark/subst_global/metrics/main.py
@@ -1,5 +1,5 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
metrics.set_benchmark(yc.execute_benchmark('util/string/benchmark/subst_global/subst_global', threads=8))
diff --git a/util/string/benchmark/subst_global/metrics/ya.make b/util/string/benchmark/subst_global/metrics/ya.make
index 73757bebcb..d8c30ad460 100644
--- a/util/string/benchmark/subst_global/metrics/ya.make
+++ b/util/string/benchmark/subst_global/metrics/ya.make
@@ -1,21 +1,21 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/string/benchmark/subst_global)
-
-END()
+
+END()
diff --git a/util/string/benchmark/subst_global/ya.make b/util/string/benchmark/subst_global/ya.make
index 30955f3189..8136ad34f0 100644
--- a/util/string/benchmark/subst_global/ya.make
+++ b/util/string/benchmark/subst_global/ya.make
@@ -1,12 +1,12 @@
OWNER(yazevnul)
-
+
Y_BENCHMARK()
-
+
# to minimize allocations overhead
ALLOCATOR(B)
-
-SRCS(
- main.cpp
-)
-
-END()
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/string/benchmark/ya.make b/util/string/benchmark/ya.make
index 09b112034d..266b53c7b3 100644
--- a/util/string/benchmark/ya.make
+++ b/util/string/benchmark/ya.make
@@ -1,16 +1,16 @@
-OWNER(
+OWNER(
g:util
- yazevnul
-)
+ yazevnul
+)
SUBSCRIBER(g:util-subscribers)
-
-RECURSE(
+
+RECURSE(
ascii
cast
- float_to_string
- float_to_string/metrics
+ float_to_string
+ float_to_string/metrics
join
join/metrics
- subst_global
- subst_global/metrics
-)
+ subst_global
+ subst_global/metrics
+)
diff --git a/util/string/builder.cpp b/util/string/builder.cpp
index e1f696c931..a3821d3399 100644
--- a/util/string/builder.cpp
+++ b/util/string/builder.cpp
@@ -3,6 +3,6 @@
#include <util/stream/output.h>
template <>
-void Out<TStringBuilder>(IOutputStream& os, const TStringBuilder& sb) {
+void Out<TStringBuilder>(IOutputStream& os, const TStringBuilder& sb) {
os << static_cast<const TString&>(sb);
}
diff --git a/util/string/builder_ut.cpp b/util/string/builder_ut.cpp
index 49d1882266..22def683ec 100644
--- a/util/string/builder_ut.cpp
+++ b/util/string/builder_ut.cpp
@@ -17,19 +17,19 @@ struct TClassWithStreamOperator {
}
};
-IOutputStream& operator<<(IOutputStream& out, const TClassWithStreamOperator& value) {
+IOutputStream& operator<<(IOutputStream& out, const TClassWithStreamOperator& value) {
return out << value.Id << " " << value.Name;
}
-Y_UNIT_TEST_SUITE(TStringBuilderTest) {
- Y_UNIT_TEST(TestStringBuilder) {
+Y_UNIT_TEST_SUITE(TStringBuilderTest) {
+ Y_UNIT_TEST(TestStringBuilder) {
TestEquals("", TStringBuilder());
TestEquals("a", TStringBuilder() << "a");
TestEquals("a1", TStringBuilder() << "a" << 1);
TestEquals("value: 123 name", TStringBuilder() << "value: " << TClassWithStreamOperator(123, "name"));
}
- Y_UNIT_TEST(TestStringBuilderOut) {
+ Y_UNIT_TEST(TestStringBuilderOut) {
TString s;
TStringOutput out(s);
TStringBuilder sb;
@@ -38,7 +38,7 @@ Y_UNIT_TEST_SUITE(TStringBuilderTest) {
TestEquals("a", s);
}
- Y_UNIT_TEST(TestStringBuilderRValue) {
+ Y_UNIT_TEST(TestStringBuilderRValue) {
struct TRValueAcceptTester {
static bool IsRValue(const TString&) {
return false;
diff --git a/util/string/cast.cpp b/util/string/cast.cpp
index d1165cade1..aa1e65a8e9 100644
--- a/util/string/cast.cpp
+++ b/util/string/cast.cpp
@@ -30,123 +30,123 @@ using double_conversion::StringToDoubleConverter;
* ------------------------------ formatters ------------------------------
*/
-namespace {
+namespace {
constexpr char IntToChar[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
-
- static_assert(Y_ARRAY_SIZE(IntToChar) == 16, "expect Y_ARRAY_SIZE(IntToChar) == 16");
-
+
+ static_assert(Y_ARRAY_SIZE(IntToChar) == 16, "expect Y_ARRAY_SIZE(IntToChar) == 16");
+
// clang-format off
constexpr int LetterToIntMap[] = {
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 0, 1,
- 2, 3, 4, 5, 6, 7, 8, 9, 20, 20,
- 20, 20, 20, 20, 20, 10, 11, 12, 13, 14,
- 15, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 10, 11, 12,
- 13, 14, 15,
- };
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 0, 1,
+ 2, 3, 4, 5, 6, 7, 8, 9, 20, 20,
+ 20, 20, 20, 20, 20, 10, 11, 12, 13, 14,
+ 15, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 10, 11, 12,
+ 13, 14, 15,
+ };
// clang-format on
-
- template <class T>
+
+ template <class T>
std::enable_if_t<std::is_signed<T>::value, std::make_unsigned_t<T>> NegateNegativeSigned(T value) noexcept {
return std::make_unsigned_t<T>(-(value + 1)) + std::make_unsigned_t<T>(1);
}
- template <class T>
+ template <class T>
std::enable_if_t<std::is_unsigned<T>::value, std::make_unsigned_t<T>> NegateNegativeSigned(T) noexcept {
Y_UNREACHABLE();
- }
+ }
template <class T>
std::make_signed_t<T> NegatePositiveSigned(T value) noexcept {
return value > 0 ? (-std::make_signed_t<T>(value - 1) - 1) : 0;
}
- template <class T, unsigned base, class TChar>
- struct TBasicIntFormatter {
- static_assert(1 < base && base < 17, "expect 1 < base && base < 17");
+ template <class T, unsigned base, class TChar>
+ struct TBasicIntFormatter {
+ static_assert(1 < base && base < 17, "expect 1 < base && base < 17");
static_assert(std::is_unsigned<T>::value, "TBasicIntFormatter can only handle unsigned integers.");
- static inline size_t Format(T value, TChar* buf, size_t len) {
+ static inline size_t Format(T value, TChar* buf, size_t len) {
Y_ENSURE(len, TStringBuf("zero length"));
- TChar* tmp = buf;
-
- do {
+ TChar* tmp = buf;
+
+ do {
// divide only once, do not use mod
const T nextVal = static_cast<T>(value / base);
*tmp++ = IntToChar[base == 2 || base == 4 || base == 8 || base == 16 ? value & (base - 1) : value - base * nextVal];
value = nextVal;
- } while (value && --len);
-
+ } while (value && --len);
+
Y_ENSURE(!value, TStringBuf("not enough room in buffer"));
-
- const size_t result = tmp - buf;
-
- --tmp;
-
- while (buf < tmp) {
- TChar c = *buf;
-
- *buf = *tmp;
- *tmp = c;
- ++buf;
- --tmp;
- }
-
- return result;
+
+ const size_t result = tmp - buf;
+
+ --tmp;
+
+ while (buf < tmp) {
+ TChar c = *buf;
+
+ *buf = *tmp;
+ *tmp = c;
+ ++buf;
+ --tmp;
+ }
+
+ return result;
}
- };
+ };
- template <class T, unsigned base, class TChar>
- struct TIntFormatter {
- static_assert(1 < base && base < 17, "expect 1 < base && base < 17");
+ template <class T, unsigned base, class TChar>
+ struct TIntFormatter {
+ static_assert(1 < base && base < 17, "expect 1 < base && base < 17");
static_assert(std::is_integral<T>::value, "T must be an integral type.");
- static inline size_t Format(T value, TChar* buf, size_t len) {
+ static inline size_t Format(T value, TChar* buf, size_t len) {
using TUFmt = TBasicIntFormatter<std::make_unsigned_t<T>, base, TChar>;
-
+
if (std::is_signed<T>::value && value < 0) {
Y_ENSURE(len >= 2, TStringBuf("not enough room in buffer"));
-
- *buf = '-';
+
+ *buf = '-';
return 1 + TUFmt::Format(NegateNegativeSigned(value), buf + 1, len - 1);
- }
-
+ }
+
return TUFmt::Format(value, buf, len);
}
- };
+ };
- template <class T>
- struct TFltModifiers;
+ template <class T>
+ struct TFltModifiers;
- template <class T, int base, class TChar>
+ template <class T, int base, class TChar>
Y_NO_INLINE size_t FormatInt(T value, TChar* buf, size_t len) {
- return TIntFormatter<T, base, TChar>::Format(value, buf, len);
- }
+ return TIntFormatter<T, base, TChar>::Format(value, buf, len);
+ }
- template <class T>
+ template <class T>
inline size_t FormatFlt(T t, char* buf, size_t len) {
- const int ret = snprintf(buf, len, TFltModifiers<T>::ModifierWrite, t);
+ const int ret = snprintf(buf, len, TFltModifiers<T>::ModifierWrite, t);
Y_ENSURE(ret >= 0 && (size_t)ret <= len, TStringBuf("cannot format float"));
- return (size_t)ret;
+ return (size_t)ret;
}
- enum EParseStatus {
- PS_OK = 0,
- PS_EMPTY_STRING,
- PS_PLUS_STRING,
- PS_MINUS_STRING,
- PS_BAD_SYMBOL,
- PS_OVERFLOW,
- };
+ enum EParseStatus {
+ PS_OK = 0,
+ PS_EMPTY_STRING,
+ PS_PLUS_STRING,
+ PS_MINUS_STRING,
+ PS_BAD_SYMBOL,
+ PS_OVERFLOW,
+ };
constexpr ui8 SAFE_LENS[4][17] = {
{0, 0, 7, 5, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1},
@@ -177,19 +177,19 @@ namespace {
return (c >= '0') && ((*digit = (c - '0')) < BASE);
}
- template <class T, unsigned base, class TChar>
- struct TBasicIntParser {
- static_assert(1 < base && base < 17, "Expect 1 < base && base < 17.");
+ template <class T, unsigned base, class TChar>
+ struct TBasicIntParser {
+ static_assert(1 < base && base < 17, "Expect 1 < base && base < 17.");
static_assert(std::is_unsigned<T>::value, "TBasicIntParser can only handle unsigned integers.");
-
+
enum : unsigned {
BASE_POW_2 = base * base,
};
static inline EParseStatus Parse(const TChar** ppos, const TChar* end, T max, T* target) noexcept {
- Y_ASSERT(*ppos != end); /* This check should be somewhere up the stack. */
+ Y_ASSERT(*ppos != end); /* This check should be somewhere up the stack. */
const size_t maxSafeLen = SAFE_LENS[ConstLog2(sizeof(T))][base];
-
+
// can parse without overflow
if (size_t(end - *ppos) <= maxSafeLen) {
T result;
@@ -205,7 +205,7 @@ namespace {
}
static inline bool ParseFast(const TChar* pos, const TChar* end, T* target) noexcept {
- T result = T();
+ T result = T();
T d1;
T d2;
@@ -229,164 +229,164 @@ namespace {
static inline EParseStatus ParseSlow(const TChar** ppos, const TChar* end, T max, T* target) noexcept {
T result = T();
- T preMulMax = max / base;
- const TChar* pos = *ppos;
-
- while (pos != end) {
- T digit;
+ T preMulMax = max / base;
+ const TChar* pos = *ppos;
+
+ while (pos != end) {
+ T digit;
if (!CharToDigit<base>(*pos, &digit)) {
- *ppos = pos;
-
- return PS_BAD_SYMBOL;
- }
-
- if (result > preMulMax) {
- return PS_OVERFLOW;
- }
-
- result *= base;
-
- if (result > max - digit) {
- return PS_OVERFLOW;
- }
-
- result += digit;
- pos++;
- }
-
- *target = result;
-
- return PS_OK;
- }
+ *ppos = pos;
+
+ return PS_BAD_SYMBOL;
+ }
+
+ if (result > preMulMax) {
+ return PS_OVERFLOW;
+ }
+
+ result *= base;
+
+ if (result > max - digit) {
+ return PS_OVERFLOW;
+ }
+
+ result += digit;
+ pos++;
+ }
+
+ *target = result;
+
+ return PS_OK;
+ }
};
- template <class T>
- struct TBounds {
- T PositiveMax;
- T NegativeMax;
- };
+ template <class T>
+ struct TBounds {
+ T PositiveMax;
+ T NegativeMax;
+ };
- template <class T, unsigned base, class TChar>
- struct TIntParser {
- static_assert(1 < base && base < 17, "Expect 1 < base && base < 17.");
+ template <class T, unsigned base, class TChar>
+ struct TIntParser {
+ static_assert(1 < base && base < 17, "Expect 1 < base && base < 17.");
static_assert(std::is_integral<T>::value, "T must be an integral type.");
- enum {
+ enum {
IsSigned = std::is_signed<T>::value
- };
-
- using TUnsigned = std::make_unsigned_t<T>;
-
- static inline EParseStatus Parse(const TChar** ppos, const TChar* end, const TBounds<TUnsigned>& bounds, T* target) {
- const TChar* pos = *ppos;
- if (pos == end) {
- return PS_EMPTY_STRING;
+ };
+
+ using TUnsigned = std::make_unsigned_t<T>;
+
+ static inline EParseStatus Parse(const TChar** ppos, const TChar* end, const TBounds<TUnsigned>& bounds, T* target) {
+ const TChar* pos = *ppos;
+ if (pos == end) {
+ return PS_EMPTY_STRING;
}
bool negative = false;
- TUnsigned max;
- if (*pos == '+') {
- pos++;
- max = bounds.PositiveMax;
-
- if (pos == end) {
- return PS_PLUS_STRING;
- }
- } else if (IsSigned && *pos == '-') {
- pos++;
- max = bounds.NegativeMax;
- negative = true;
-
- if (pos == end) {
- return PS_MINUS_STRING;
- }
- } else {
- max = bounds.PositiveMax;
- }
-
- TUnsigned result;
- EParseStatus error = TBasicIntParser<TUnsigned, base, TChar>::Parse(&pos, end, max, &result);
- if (error != PS_OK) {
+ TUnsigned max;
+ if (*pos == '+') {
+ pos++;
+ max = bounds.PositiveMax;
+
+ if (pos == end) {
+ return PS_PLUS_STRING;
+ }
+ } else if (IsSigned && *pos == '-') {
+ pos++;
+ max = bounds.NegativeMax;
+ negative = true;
+
+ if (pos == end) {
+ return PS_MINUS_STRING;
+ }
+ } else {
+ max = bounds.PositiveMax;
+ }
+
+ TUnsigned result;
+ EParseStatus error = TBasicIntParser<TUnsigned, base, TChar>::Parse(&pos, end, max, &result);
+ if (error != PS_OK) {
*ppos = pos;
- return error;
- }
-
- if (IsSigned) {
+ return error;
+ }
+
+ if (IsSigned) {
*target = negative ? NegatePositiveSigned(result) : static_cast<T>(result);
- } else {
- *target = result;
- }
- return PS_OK;
+ } else {
+ *target = result;
+ }
+ return PS_OK;
}
- };
+ };
- template <class TChar>
+ template <class TChar>
[[noreturn]] static Y_NO_INLINE void ThrowParseError(EParseStatus status, const TChar* data, size_t len, const TChar* pos) {
- Y_ASSERT(status != PS_OK);
-
+ Y_ASSERT(status != PS_OK);
+
typedef TBasicString<TChar> TStringType;
-
- switch (status) {
- case PS_EMPTY_STRING:
+
+ switch (status) {
+ case PS_EMPTY_STRING:
ythrow TFromStringException() << TStringBuf("Cannot parse empty string as number. ");
- case PS_PLUS_STRING:
+ case PS_PLUS_STRING:
ythrow TFromStringException() << TStringBuf("Cannot parse string \"+\" as number. ");
- case PS_MINUS_STRING:
+ case PS_MINUS_STRING:
ythrow TFromStringException() << TStringBuf("Cannot parse string \"-\" as number. ");
- case PS_BAD_SYMBOL:
+ case PS_BAD_SYMBOL:
ythrow TFromStringException() << TStringBuf("Unexpected symbol \"") << EscapeC(*pos) << TStringBuf("\" at pos ") << (pos - data) << TStringBuf(" in string ") << TStringType(data, len).Quote() << TStringBuf(". ");
- case PS_OVERFLOW:
+ case PS_OVERFLOW:
ythrow TFromStringException() << TStringBuf("Integer overflow in string ") << TStringType(data, len).Quote() << TStringBuf(". ");
- default:
+ default:
ythrow yexception() << TStringBuf("Unknown error code in string converter. ");
- }
+ }
}
- template <typename T, typename TUnsigned, int base, typename TChar>
+ template <typename T, typename TUnsigned, int base, typename TChar>
Y_NO_INLINE T ParseInt(const TChar* data, size_t len, const TBounds<TUnsigned>& bounds) {
- T result;
- const TChar* pos = data;
- EParseStatus status = TIntParser<T, base, TChar>::Parse(&pos, pos + len, bounds, &result);
-
- if (status == PS_OK) {
- return result;
- } else {
- ThrowParseError(status, data, len, pos);
- }
- }
-
- template <typename T, typename TUnsigned, int base, typename TChar>
+ T result;
+ const TChar* pos = data;
+ EParseStatus status = TIntParser<T, base, TChar>::Parse(&pos, pos + len, bounds, &result);
+
+ if (status == PS_OK) {
+ return result;
+ } else {
+ ThrowParseError(status, data, len, pos);
+ }
+ }
+
+ template <typename T, typename TUnsigned, int base, typename TChar>
Y_NO_INLINE bool TryParseInt(const TChar* data, size_t len, const TBounds<TUnsigned>& bounds, T* result) {
- return TIntParser<T, base, TChar>::Parse(&data, data + len, bounds, result) == PS_OK;
- }
-
- template <class T>
+ return TIntParser<T, base, TChar>::Parse(&data, data + len, bounds, result) == PS_OK;
+ }
+
+ template <class T>
inline T ParseFlt(const char* data, size_t len) {
- /*
- * TODO
- */
-
- if (len > 256) {
- len = 256;
- }
-
- char* c = (char*)alloca(len + 1);
- memcpy(c, data, len);
- c[len] = 0;
-
- T ret;
- char ec;
-
- // try to read a value and an extra character in order to catch cases when
- // the string start with a valid float but is followed by unexpected characters
- if (sscanf(c, TFltModifiers<T>::ModifierReadAndChar, &ret, &ec) == 1) {
- return ret;
- }
-
+ /*
+ * TODO
+ */
+
+ if (len > 256) {
+ len = 256;
+ }
+
+ char* c = (char*)alloca(len + 1);
+ memcpy(c, data, len);
+ c[len] = 0;
+
+ T ret;
+ char ec;
+
+ // try to read a value and an extra character in order to catch cases when
+ // the string start with a valid float but is followed by unexpected characters
+ if (sscanf(c, TFltModifiers<T>::ModifierReadAndChar, &ret, &ec) == 1) {
+ return ret;
+ }
+
ythrow TFromStringException() << TStringBuf("cannot parse float(") << TStringBuf(data, len) << TStringBuf(")");
- }
-
+ }
+
#define DEF_FLT_MOD(type, modifierWrite, modifierRead) \
template <> \
struct TFltModifiers<type> { \
@@ -397,14 +397,14 @@ namespace {
const char* const TFltModifiers<type>::ModifierWrite = modifierWrite; \
const char* const TFltModifiers<type>::ModifierReadAndChar = modifierRead "%c";
- DEF_FLT_MOD(long double, "%.10Lg", "%Lg")
+ DEF_FLT_MOD(long double, "%.10Lg", "%Lg")
#undef DEF_FLT_MOD
- /* The following constants are initialized in terms of <climits> constants to make
- * sure they go into binary as actual values and there is no associated
- * initialization code.
- * */
+ /* The following constants are initialized in terms of <climits> constants to make
+ * sure they go into binary as actual values and there is no associated
+ * initialization code.
+ * */
constexpr TBounds<ui64> bSBounds = {static_cast<ui64>(SCHAR_MAX), static_cast<ui64>(UCHAR_MAX - SCHAR_MAX)};
constexpr TBounds<ui64> bUBounds = {static_cast<ui64>(UCHAR_MAX), 0};
constexpr TBounds<ui64> sSBounds = {static_cast<ui64>(SHRT_MAX), static_cast<ui64>(USHRT_MAX - SHRT_MAX)};
@@ -450,8 +450,8 @@ size_t ToStringImpl<char8_t>(char8_t value, char* buf, size_t len) {
}
#endif
-using TCharIType = std::conditional_t<std::is_signed<char>::value, i64, ui64>;
-using TWCharIType = std::conditional_t<std::is_signed<wchar_t>::value, i64, ui64>;
+using TCharIType = std::conditional_t<std::is_signed<char>::value, i64, ui64>;
+using TWCharIType = std::conditional_t<std::is_signed<wchar_t>::value, i64, ui64>;
DEF_INT_SPEC_I(char, TCharIType)
DEF_INT_SPEC_I(wchar_t, TWCharIType)
@@ -472,13 +472,13 @@ DEF_FLT_SPEC(long double)
#undef DEF_FLT_SPEC
-template <>
-size_t ToStringImpl<bool>(bool t, char* buf, size_t len) {
+template <>
+size_t ToStringImpl<bool>(bool t, char* buf, size_t len) {
Y_ENSURE(len, TStringBuf("zero length"));
- *buf = t ? '1' : '0';
- return 1;
-}
-
+ *buf = t ? '1' : '0';
+ return 1;
+}
+
/*
* ------------------------------ parsers ------------------------------
*/
@@ -543,12 +543,12 @@ TWtringBuf FromStringImpl<TWtringBuf>(const wchar16* data, size_t len) {
// Try-versions
template <>
-bool TryFromStringImpl<TStringBuf>(const char* data, size_t len, TStringBuf& result) {
- result = {data, len};
- return true;
-}
-
-template <>
+bool TryFromStringImpl<TStringBuf>(const char* data, size_t len, TStringBuf& result) {
+ result = {data, len};
+ return true;
+}
+
+template <>
bool TryFromStringImpl<TString>(const char* data, size_t len, TString& result) {
result = TString(data, len);
return true;
@@ -561,12 +561,12 @@ bool TryFromStringImpl<std::string>(const char* data, size_t len, std::string& r
}
template <>
-bool TryFromStringImpl<TWtringBuf>(const wchar16* data, size_t len, TWtringBuf& result) {
- result = {data, len};
- return true;
-}
-
-template <>
+bool TryFromStringImpl<TWtringBuf>(const wchar16* data, size_t len, TWtringBuf& result) {
+ result = {data, len};
+ return true;
+}
+
+template <>
bool TryFromStringImpl<TUtf16String>(const wchar16* data, size_t len, TUtf16String& result) {
result = TUtf16String(data, len);
return true;
@@ -648,7 +648,7 @@ bool TryFromStringImpl<double>(const char* data, size_t len, double& result) {
return false;
}
- char* se = nullptr;
+ char* se = nullptr;
double d = StrToD(data, data + len, &se);
if (se != data + len) {
diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp
index e6fec11e2c..033450c38c 100644
--- a/util/string/cast_ut.cpp
+++ b/util/string/cast_ut.cpp
@@ -149,7 +149,7 @@ inline void CheckConvertToBuffer(const T& value, const size_t size, const TStrin
}
#endif
-Y_UNIT_TEST_SUITE(TCastTest) {
+Y_UNIT_TEST_SUITE(TCastTest) {
template <class A>
inline TRet<A> F() {
return TRet<A>();
@@ -173,10 +173,10 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_VALUES_EQUAL(res, false);
UNIT_ASSERT_DOUBLES_EQUAL(f, 42.0, eps); // check value was not trashed
UNIT_ASSERT_EXCEPTION(f = FromString<TFloat>(str), TFromStringException);
- Y_UNUSED(f); // shut up compiler about 'assigned value that is not used'
+ Y_UNUSED(f); // shut up compiler about 'assigned value that is not used'
}
- Y_UNIT_TEST(TestToFrom) {
+ Y_UNIT_TEST(TestToFrom) {
test1(bool, true);
test1(bool, false);
test2(bool, "");
@@ -229,18 +229,18 @@ Y_UNIT_TEST_SUITE(TCastTest) {
test1(long long int, LLONG_MIN + 1);
}
- Y_UNIT_TEST(TestVolatile) {
+ Y_UNIT_TEST(TestVolatile) {
volatile int x = 1;
UNIT_ASSERT_VALUES_EQUAL(ToString(x), "1");
}
- Y_UNIT_TEST(TestStrToD) {
- UNIT_ASSERT_DOUBLES_EQUAL(StrToD("1.1", nullptr), 1.1, EPS);
- UNIT_ASSERT_DOUBLES_EQUAL(StrToD("1.12345678", nullptr), 1.12345678, EPS);
- UNIT_ASSERT_DOUBLES_EQUAL(StrToD("10E-5", nullptr), 10E-5, EPS);
- UNIT_ASSERT_DOUBLES_EQUAL(StrToD("1.1E+5", nullptr), 1.1E+5, EPS);
+ Y_UNIT_TEST(TestStrToD) {
+ UNIT_ASSERT_DOUBLES_EQUAL(StrToD("1.1", nullptr), 1.1, EPS);
+ UNIT_ASSERT_DOUBLES_EQUAL(StrToD("1.12345678", nullptr), 1.12345678, EPS);
+ UNIT_ASSERT_DOUBLES_EQUAL(StrToD("10E-5", nullptr), 10E-5, EPS);
+ UNIT_ASSERT_DOUBLES_EQUAL(StrToD("1.1E+5", nullptr), 1.1E+5, EPS);
- char* ret = nullptr;
+ char* ret = nullptr;
UNIT_ASSERT_DOUBLES_EQUAL(StrToD("1.1y", &ret), 1.1, EPS);
UNIT_ASSERT_VALUES_EQUAL(*ret, 'y');
@@ -252,7 +252,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_VALUES_EQUAL(*ret, 'z');
}
- Y_UNIT_TEST(TestFloats) {
+ Y_UNIT_TEST(TestFloats) {
// "%g" mode
UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.1f, PREC_NDIGITS, 6), "0.1"); // drop trailing zeroes
UNIT_ASSERT_VALUES_EQUAL(FloatToString(0.12345678f, PREC_NDIGITS, 6), "0.123457");
@@ -289,7 +289,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_STRINGS_EQUAL(FloatToString(-std::numeric_limits<float>::infinity()), "-inf");
}
- Y_UNIT_TEST(TestReadFloats) {
+ Y_UNIT_TEST(TestReadFloats) {
GoodFloatTester<float>("0.0001", 0.0001f, EPS);
GoodFloatTester<double>("0.0001", 0.0001, EPS);
GoodFloatTester<long double>("0.0001", 0.0001, EPS);
@@ -303,24 +303,24 @@ Y_UNIT_TEST_SUITE(TCastTest) {
//BadFloatTester<float>("10E");
//BadFloatTester<float>("10.E");
BadFloatTester<float>("..0");
- BadFloatTester<float>(""); // IGNIETFERRO-300
+ BadFloatTester<float>(""); // IGNIETFERRO-300
BadFloatTester<double>("1.00.01");
BadFloatTester<double>("1.0001E5b");
BadFloatTester<double>("1.0001s");
BadFloatTester<double>("1..01");
- BadFloatTester<double>(""); // IGNIETFERRO-300
+ BadFloatTester<double>(""); // IGNIETFERRO-300
BadFloatTester<long double>(".1.00");
BadFloatTester<long double>("1.00.");
BadFloatTester<long double>("1.0001e5-");
BadFloatTester<long double>("10e 2");
- BadFloatTester<long double>(""); // IGNIETFERRO-300
+ BadFloatTester<long double>(""); // IGNIETFERRO-300
}
- Y_UNIT_TEST(TestLiteral) {
+ Y_UNIT_TEST(TestLiteral) {
UNIT_ASSERT_VALUES_EQUAL(ToString("abc"), TString("abc"));
}
- Y_UNIT_TEST(TestFromStringStringBuf) {
+ Y_UNIT_TEST(TestFromStringStringBuf) {
TString a = "xyz";
TStringBuf b = FromString<TStringBuf>(a);
UNIT_ASSERT_VALUES_EQUAL(a, b);
@@ -328,7 +328,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
}
#if 0
- Y_UNIT_TEST(TestBufferOverflow) {
+ Y_UNIT_TEST(TestBufferOverflow) {
CheckConvertToBuffer<float>(1.f, 5, "1");
CheckConvertToBuffer<float>(1.005f, 3, "1.005");
CheckConvertToBuffer<float>(1.00000000f, 3, "1");
@@ -349,7 +349,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
}
#endif
- Y_UNIT_TEST(TestWide) {
+ Y_UNIT_TEST(TestWide) {
TUtf16String iw = u"-100500";
int iv = 0;
UNIT_ASSERT_VALUES_EQUAL(TryFromString(iw, iv), true);
@@ -371,7 +371,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_VALUES_EQUAL(uv, 21474836470ull);
}
- Y_UNIT_TEST(TestDefault) {
+ Y_UNIT_TEST(TestDefault) {
size_t res = 0;
const size_t def1 = 42;
@@ -437,7 +437,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_VALUES_EQUAL(FromStringWithDefault<size_t>(s4), size_t());
}
- Y_UNIT_TEST(TestBool) {
+ Y_UNIT_TEST(TestBool) {
// True cases
UNIT_ASSERT_VALUES_EQUAL(FromString<bool>("yes"), true);
UNIT_ASSERT_VALUES_EQUAL(FromString<bool>("1"), true);
@@ -449,7 +449,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_EXCEPTION(FromString<bool>("something"), yexception);
}
- Y_UNIT_TEST(TestAutoDetectType) {
+ Y_UNIT_TEST(TestAutoDetectType) {
UNIT_ASSERT_DOUBLES_EQUAL((float)FromString("0.0001"), 0.0001, EPS);
UNIT_ASSERT_DOUBLES_EQUAL((double)FromString("0.0015", sizeof("0.0015") - 2), 0.001, EPS);
UNIT_ASSERT_DOUBLES_EQUAL((long double)FromString(TStringBuf("0.0001")), 0.0001, EPS);
@@ -472,7 +472,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
}
}
- Y_UNIT_TEST(ErrorMessages) {
+ Y_UNIT_TEST(ErrorMessages) {
try {
FromString<ui32>("");
UNIT_ASSERT(false);
@@ -509,47 +509,47 @@ Y_UNIT_TEST_SUITE(TCastTest) {
CheckMessage(e, "Unexpected symbol \".\" at pos 1 in string \"0.328413745072\"");
}
}
-
- Y_UNIT_TEST(TryStringBuf) {
- {
+
+ Y_UNIT_TEST(TryStringBuf) {
+ {
constexpr TStringBuf hello = "hello";
- TStringBuf out;
- UNIT_ASSERT(TryFromString(hello, out));
+ TStringBuf out;
+ UNIT_ASSERT(TryFromString(hello, out));
UNIT_ASSERT_VALUES_EQUAL(hello, out);
- }
- {
+ }
+ {
constexpr TStringBuf empty = "";
- TStringBuf out;
- UNIT_ASSERT(TryFromString(empty, out));
+ TStringBuf out;
+ UNIT_ASSERT(TryFromString(empty, out));
UNIT_ASSERT_VALUES_EQUAL(empty, out);
- }
- {
- constexpr TStringBuf empty;
- TStringBuf out;
- UNIT_ASSERT(TryFromString(empty, out));
+ }
+ {
+ constexpr TStringBuf empty;
+ TStringBuf out;
+ UNIT_ASSERT(TryFromString(empty, out));
UNIT_ASSERT_VALUES_EQUAL(empty, out);
- }
- {
+ }
+ {
const auto hello = u"hello";
- TWtringBuf out;
- UNIT_ASSERT(TryFromString(hello, out));
+ TWtringBuf out;
+ UNIT_ASSERT(TryFromString(hello, out));
UNIT_ASSERT_VALUES_EQUAL(hello, out);
- }
- {
+ }
+ {
const TUtf16String empty;
- TWtringBuf out;
- UNIT_ASSERT(TryFromString(empty, out));
+ TWtringBuf out;
+ UNIT_ASSERT(TryFromString(empty, out));
UNIT_ASSERT_VALUES_EQUAL(empty, out);
- }
- {
- constexpr TWtringBuf empty;
- TWtringBuf out;
- UNIT_ASSERT(TryFromString(empty, out));
+ }
+ {
+ constexpr TWtringBuf empty;
+ TWtringBuf out;
+ UNIT_ASSERT(TryFromString(empty, out));
UNIT_ASSERT_VALUES_EQUAL(empty, out);
- }
- }
+ }
+ }
- Y_UNIT_TEST(Nan) {
+ Y_UNIT_TEST(Nan) {
double xx = 0;
UNIT_ASSERT(!TryFromString("NaN", xx));
@@ -557,7 +557,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT(!TryFromString("nan", xx));
}
- Y_UNIT_TEST(Infinity) {
+ Y_UNIT_TEST(Infinity) {
double xx = 0;
UNIT_ASSERT(!TryFromString("Infinity", xx));
@@ -565,7 +565,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT(!TryFromString("infinity", xx));
}
- Y_UNIT_TEST(TestBorderCases) {
+ Y_UNIT_TEST(TestBorderCases) {
UNIT_ASSERT_VALUES_EQUAL(ToString(0.0), "0");
UNIT_ASSERT_VALUES_EQUAL(ToString(1.0), "1");
UNIT_ASSERT_VALUES_EQUAL(ToString(10.0), "10");
diff --git a/util/string/escape.cpp b/util/string/escape.cpp
index 0a79bd30d0..cd09a7dbd0 100644
--- a/util/string/escape.cpp
+++ b/util/string/escape.cpp
@@ -43,7 +43,7 @@
namespace {
template <typename TChar>
static inline char HexDigit(TChar value) {
- Y_ASSERT(value < 16);
+ Y_ASSERT(value < 16);
if (value < 10) {
return '0' + value;
} else {
@@ -53,7 +53,7 @@ namespace {
template <typename TChar>
static inline char OctDigit(TChar value) {
- Y_ASSERT(value < 8);
+ Y_ASSERT(value < 8);
return '0' + value;
}
diff --git a/util/string/escape_ut.cpp b/util/string/escape_ut.cpp
index b1bd7f2a94..cd38ecffd3 100644
--- a/util/string/escape_ut.cpp
+++ b/util/string/escape_ut.cpp
@@ -7,20 +7,20 @@
using namespace std::string_view_literals;
-namespace {
- struct TExample {
+namespace {
+ struct TExample {
TString Expected;
TString Source;
-
- TExample(const TStringBuf expected, const TStringBuf source)
- : Expected{expected}
+
+ TExample(const TStringBuf expected, const TStringBuf source)
+ : Expected{expected}
, Source{source}
{
- }
- };
-}
-
-static const TExample CommonTestData[] = {
+ }
+ };
+}
+
+static const TExample CommonTestData[] = {
// Should be valid UTF-8.
{"http://ya.ru/", "http://ya.ru/"},
{"http://ya.ru/\\x17\\n", "http://ya.ru/\x17\n"},
@@ -46,16 +46,16 @@ static const TExample CommonTestData[] = {
{"There are questions \\x3F?", "There are questions ??"},
};
-Y_UNIT_TEST_SUITE(TEscapeCTest) {
- Y_UNIT_TEST(TestStrokaEscapeC) {
- for (const auto& e : CommonTestData) {
+Y_UNIT_TEST_SUITE(TEscapeCTest) {
+ Y_UNIT_TEST(TestStrokaEscapeC) {
+ for (const auto& e : CommonTestData) {
TString expected(e.Expected);
TString source(e.Source);
TString actual(EscapeC(e.Source));
TString actual2(UnescapeC(e.Expected));
- UNIT_ASSERT_VALUES_EQUAL(e.Expected, actual);
- UNIT_ASSERT_VALUES_EQUAL(e.Source, actual2);
+ UNIT_ASSERT_VALUES_EQUAL(e.Expected, actual);
+ UNIT_ASSERT_VALUES_EQUAL(e.Source, actual2);
}
UNIT_ASSERT_VALUES_EQUAL("http://ya.ru/\\x17\\n\\xAB", EscapeC(TString("http://ya.ru/\x17\n\xab")));
@@ -79,8 +79,8 @@ Y_UNIT_TEST_SUITE(TEscapeCTest) {
UNIT_ASSERT_VALUES_EQUAL("Странный компроматтест", UnescapeC(TString("\\u0421\\u0442\\u0440\\u0430\\u043d\\u043d\\u044b\\u0439 \\u043a\\u043e\\u043c\\u043f\\u0440\\u043e\\u043c\\u0430\\u0442тест")));
}
- Y_UNIT_TEST(TestWtrokaEscapeC) {
- for (const auto& e : CommonTestData) {
+ Y_UNIT_TEST(TestWtrokaEscapeC) {
+ for (const auto& e : CommonTestData) {
TUtf16String expected(UTF8ToWide(e.Expected));
TUtf16String source(UTF8ToWide(e.Source));
TUtf16String actual(EscapeC(source));
@@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(TEscapeCTest) {
UNIT_ASSERT_VALUES_EQUAL(u"\\xFF", EscapeC(wchar16(255)));
}
- Y_UNIT_TEST(TestEscapeTrigraphs) {
+ Y_UNIT_TEST(TestEscapeTrigraphs) {
UNIT_ASSERT_VALUES_EQUAL("?", EscapeC(TString("?")));
UNIT_ASSERT_VALUES_EQUAL("\\x3F?", EscapeC(TString("??")));
UNIT_ASSERT_VALUES_EQUAL("\\x3F\\x3F?", EscapeC(TString("???")));
@@ -104,7 +104,7 @@ Y_UNIT_TEST_SUITE(TEscapeCTest) {
UNIT_ASSERT_VALUES_EQUAL("\\x3F?x\\x3F\\x3F?z", EscapeC(TString("??x???z")));
}
- Y_UNIT_TEST(TestUnescapeCCharLen) {
+ Y_UNIT_TEST(TestUnescapeCCharLen) {
auto test = [](const char* str, size_t len) {
UNIT_ASSERT_EQUAL(UnescapeCCharLen(str, str + strlen(str)), len);
};
@@ -131,7 +131,7 @@ Y_UNIT_TEST_SUITE(TEscapeCTest) {
test("\\4xxx", 2);
}
- Y_UNIT_TEST(TestUnbounded) {
+ Y_UNIT_TEST(TestUnbounded) {
char buf[100000];
for (const auto& x : CommonTestData) {
diff --git a/util/string/fuzzing/escape_c/main.cpp b/util/string/fuzzing/escape_c/main.cpp
index aa733cec76..742126416a 100644
--- a/util/string/fuzzing/escape_c/main.cpp
+++ b/util/string/fuzzing/escape_c/main.cpp
@@ -1,11 +1,11 @@
-#include <util/generic/string.h>
-#include <util/string/escape.h>
-
-extern "C" int LLVMFuzzerTestOneInput(const ui8* const data, const size_t size) {
- const TString src(reinterpret_cast<const char*>(data), size);
- const auto escaped = EscapeC(src);
- const auto dst = UnescapeC(escaped);
-
- Y_VERIFY(src == dst);
- return 0;
-}
+#include <util/generic/string.h>
+#include <util/string/escape.h>
+
+extern "C" int LLVMFuzzerTestOneInput(const ui8* const data, const size_t size) {
+ const TString src(reinterpret_cast<const char*>(data), size);
+ const auto escaped = EscapeC(src);
+ const auto dst = UnescapeC(escaped);
+
+ Y_VERIFY(src == dst);
+ return 0;
+}
diff --git a/util/string/fuzzing/escape_c/ya.make b/util/string/fuzzing/escape_c/ya.make
index 0cdee23d31..61e64ac9de 100644
--- a/util/string/fuzzing/escape_c/ya.make
+++ b/util/string/fuzzing/escape_c/ya.make
@@ -1,13 +1,13 @@
-OWNER(
- yazevnul
- g:util
-)
+OWNER(
+ yazevnul
+ g:util
+)
SUBSCRIBER(g:util-subscribers)
-
-FUZZ()
-
-SRCS(
- main.cpp
-)
-
-END()
+
+FUZZ()
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/string/fuzzing/ya.make b/util/string/fuzzing/ya.make
index e3a87d3740..617e0f2b1d 100644
--- a/util/string/fuzzing/ya.make
+++ b/util/string/fuzzing/ya.make
@@ -1,11 +1,11 @@
-OWNER(
+OWNER(
g:util
- pg
-)
+ pg
+)
SUBSCRIBER(g:util-subscribers)
-
+
RECURSE(
- collapse
- escape_c
+ collapse
+ escape_c
strtod
)
diff --git a/util/string/hex.h b/util/string/hex.h
index 08f7398129..af3d2d528f 100644
--- a/util/string/hex.h
+++ b/util/string/hex.h
@@ -16,7 +16,7 @@ extern const char* const Char2DigitTable;
inline static int Char2Digit(char ch) {
char result = Char2DigitTable[(unsigned char)ch];
- Y_ENSURE(result != '\xff', "invalid hex character " << (int)ch);
+ Y_ENSURE(result != '\xff', "invalid hex character " << (int)ch);
return result;
}
diff --git a/util/string/hex_ut.cpp b/util/string/hex_ut.cpp
index 485583ce35..39a83d5e62 100644
--- a/util/string/hex_ut.cpp
+++ b/util/string/hex_ut.cpp
@@ -2,16 +2,16 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(THexCodingTest) {
- Y_UNIT_TEST(TestEncode) {
+Y_UNIT_TEST_SUITE(THexCodingTest) {
+ Y_UNIT_TEST(TestEncode) {
UNIT_ASSERT_EQUAL(HexEncode("i1634iqwbf,&msdb"), "693136333469717762662C266D736462");
}
- Y_UNIT_TEST(TestDecode) {
+ Y_UNIT_TEST(TestDecode) {
UNIT_ASSERT_EQUAL(HexDecode("693136333469717762662C266D736462"), "i1634iqwbf,&msdb");
}
- Y_UNIT_TEST(TestDecodeCase) {
+ Y_UNIT_TEST(TestDecodeCase) {
UNIT_ASSERT_EQUAL(HexDecode("12ABCDEF"), HexDecode("12abcdef"));
UNIT_ASSERT_EXCEPTION(HexDecode("Hello"), yexception); //< incorrect chars
UNIT_ASSERT_EXCEPTION(HexDecode("123"), yexception); //< odd length
diff --git a/util/string/join_ut.cpp b/util/string/join_ut.cpp
index fde333a37d..3ed2b2459c 100644
--- a/util/string/join_ut.cpp
+++ b/util/string/join_ut.cpp
@@ -3,7 +3,7 @@
#include <library/cpp/testing/unittest/registar.h>
#include <util/generic/vector.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
struct TCustomData {
TVector<int> Ints;
@@ -13,8 +13,8 @@ TString ToString(const TCustomData& d) {
return JoinSeq("__", d.Ints);
}
-Y_UNIT_TEST_SUITE(JoinStringTest) {
- Y_UNIT_TEST(ScalarItems) {
+Y_UNIT_TEST_SUITE(JoinStringTest) {
+ Y_UNIT_TEST(ScalarItems) {
UNIT_ASSERT_EQUAL(Join(',', 10, 11.1, "foobar"), "10,11.1,foobar");
UNIT_ASSERT_EQUAL(Join(", ", 10, 11.1, "foobar"), "10, 11.1, foobar");
UNIT_ASSERT_EQUAL(Join(", ", 10, 11.1, TString("foobar")), "10, 11.1, foobar");
@@ -26,7 +26,7 @@ Y_UNIT_TEST_SUITE(JoinStringTest) {
UNIT_ASSERT_EQUAL(Join(" ", "a", "b", "", "c"), "a b c");
}
- Y_UNIT_TEST(IntContainerItems) {
+ Y_UNIT_TEST(IntContainerItems) {
int v[] = {1, 2, 3};
TVector<int> vv(v, v + 3);
UNIT_ASSERT_EQUAL(JoinSeq(" ", vv), "1 2 3");
@@ -38,7 +38,7 @@ Y_UNIT_TEST_SUITE(JoinStringTest) {
UNIT_ASSERT_VALUES_EQUAL(JoinSeq(" ", v), "1 2 3");
}
- Y_UNIT_TEST(StrContainerItems) {
+ Y_UNIT_TEST(StrContainerItems) {
// try various overloads and template type arguments
static const char* const result = "1 22 333";
static const char* const v[] = {"1", "22", "333"};
@@ -148,13 +148,13 @@ Y_UNIT_TEST_SUITE(JoinStringTest) {
UNIT_ASSERT_VALUES_EQUAL(JoinSeq(" ", v), result);
}
- Y_UNIT_TEST(CustomToString) {
- TCustomData d1{{1, 2, 3, 4, 5}};
- TCustomData d2{{0, -1, -2}};
+ Y_UNIT_TEST(CustomToString) {
+ TCustomData d1{{1, 2, 3, 4, 5}};
+ TCustomData d2{{0, -1, -2}};
UNIT_ASSERT_EQUAL(Join(" ", d1, d2), "1__2__3__4__5 0__-1__-2");
}
- Y_UNIT_TEST(JoinChars) {
+ Y_UNIT_TEST(JoinChars) {
// Note that char delimeter is printed as single char string,
// but joined char values are printed as their numeric codes! O_o
UNIT_ASSERT_EQUAL(Join('a', 'a', 'a'), "97a97");
diff --git a/util/string/printf.cpp b/util/string/printf.cpp
index a8a2e71c9d..5b7c34d4e1 100644
--- a/util/string/printf.cpp
+++ b/util/string/printf.cpp
@@ -1,7 +1,7 @@
#include "printf.h"
#include <util/stream/printf.h>
-#include <util/stream/str.h>
+#include <util/stream/str.h>
int vsprintf(TString& s, const char* c, va_list params) {
TStringOutput so(s.remove());
diff --git a/util/string/printf.h b/util/string/printf.h
index 742bf1e584..925c6edaff 100644
--- a/util/string/printf.h
+++ b/util/string/printf.h
@@ -1,10 +1,10 @@
#pragma once
#include <util/generic/fwd.h>
-#include <util/system/compiler.h>
+#include <util/system/compiler.h>
+
+#include <cstdarg>
-#include <cstdarg>
-
/// formatted print. return printed length:
int Y_PRINTF_FORMAT(2, 0) vsprintf(TString& s, const char* c, va_list params);
/// formatted print. return printed length:
diff --git a/util/string/printf_ut.cpp b/util/string/printf_ut.cpp
index b6d43cb3a2..2b2f980b70 100644
--- a/util/string/printf_ut.cpp
+++ b/util/string/printf_ut.cpp
@@ -2,15 +2,15 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TStringPrintf) {
- Y_UNIT_TEST(TestSprintf) {
+Y_UNIT_TEST_SUITE(TStringPrintf) {
+ Y_UNIT_TEST(TestSprintf) {
TString s;
int len = sprintf(s, "Hello %s", "world");
UNIT_ASSERT_EQUAL(s, TString("Hello world"));
UNIT_ASSERT_EQUAL(len, 11);
}
- Y_UNIT_TEST(TestFcat) {
+ Y_UNIT_TEST(TestFcat) {
TString s;
int len = sprintf(s, "Hello %s", "world");
UNIT_ASSERT_EQUAL(s, TString("Hello world"));
@@ -20,11 +20,11 @@ Y_UNIT_TEST_SUITE(TStringPrintf) {
UNIT_ASSERT_EQUAL(len, 7);
}
- Y_UNIT_TEST(TestSpecial) {
+ Y_UNIT_TEST(TestSpecial) {
UNIT_ASSERT_EQUAL("4294967295", Sprintf("%" PRIu32, (ui32)(-1)));
}
- Y_UNIT_TEST(TestExplicitPositions) {
+ Y_UNIT_TEST(TestExplicitPositions) {
UNIT_ASSERT_EQUAL("abc xyz abc", Sprintf("%1$s %2$s %1$s", "abc", "xyz"));
}
}
diff --git a/util/string/split.h b/util/string/split.h
index 58d8f81c5e..bc46d9e64c 100644
--- a/util/string/split.h
+++ b/util/string/split.h
@@ -261,7 +261,7 @@ struct TSetDelimiter: private TFindFirstOf<const Char> {
};
namespace NSplitTargetHasPushBack {
- Y_HAS_MEMBER(push_back, PushBack);
+ Y_HAS_MEMBER(push_back, PushBack);
}
template <class T, class = void>
diff --git a/util/string/split_ut.cpp b/util/string/split_ut.cpp
index 0135d5c3af..43e59f2d75 100644
--- a/util/string/split_ut.cpp
+++ b/util/string/split_ut.cpp
@@ -2,7 +2,7 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/charset/wide.h>
#include <util/datetime/cputimer.h>
#include <util/generic/maybe.h>
@@ -119,8 +119,8 @@ void TestLimitingConsumerOnRange(TVector<TString>& good, const char* b, const ch
UNIT_ASSERT_EQUAL(TString(limits.Last), TString(last));
}
-Y_UNIT_TEST_SUITE(SplitStringTest) {
- Y_UNIT_TEST(TestCharSingleDelimiter) {
+Y_UNIT_TEST_SUITE(SplitStringTest) {
+ Y_UNIT_TEST(TestCharSingleDelimiter) {
TString data("qw ab qwabcab");
TString canonic[] = {"qw", "ab", "", "qwabcab"};
TVector<TString> good(canonic, canonic + 4);
@@ -130,7 +130,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
TestDelimiterOnRange<TContainerConsumer>(good, data.data(), data.end(), delim);
}
- Y_UNIT_TEST(TestWideSingleDelimiter) {
+ Y_UNIT_TEST(TestWideSingleDelimiter) {
TUtf16String data(u"qw ab qwabcab");
TUtf16String canonic[] = {u"qw", u"ab", TUtf16String(), u"qwabcab"};
TVector<TUtf16String> good(canonic, canonic + 4);
@@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
TestDelimiterOnRange<TContainerConsumer>(good, data.data(), data.end(), delim);
}
- Y_UNIT_TEST(TestConvertToIntCharSingleDelimiter) {
+ Y_UNIT_TEST(TestConvertToIntCharSingleDelimiter) {
TString data("42 4242 -12345 0");
i32 canonic[] = {42, 4242, -12345, 0};
TVector<i32> good(canonic, canonic + 4);
@@ -159,7 +159,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
TestConsumerOnRange<TSkipEmptyTokens<TStrokaConsumer>>(good, data.data(), data.end(), " ");
}
- Y_UNIT_TEST(TestCharKeepDelimiters) {
+ Y_UNIT_TEST(TestCharKeepDelimiters) {
TString data("qw ab qwabcab ");
TString canonic[] = {"qw", " ", "ab", " ", "", " ", "qwabcab", " ", ""};
TVector<TString> good(canonic, canonic + 9);
@@ -168,7 +168,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
TestConsumerOnRange<TKeepDelimiters<TStrokaConsumer>>(good, data.data(), data.end(), " ");
}
- Y_UNIT_TEST(TestCharLimit) {
+ Y_UNIT_TEST(TestCharLimit) {
TString data("qw ab qwabcab ");
TString canonic[] = {"qw", "ab"};
TVector<TString> good(canonic, canonic + 2);
@@ -177,7 +177,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
TestLimitingConsumerOnRange(good, data.data(), data.end(), " ", 3, " qwabcab ");
}
- Y_UNIT_TEST(TestCharStringDelimiter) {
+ Y_UNIT_TEST(TestCharStringDelimiter) {
TString data("qw ab qwababcab");
TString canonic[] = {"qw ", " qw", "", "c", ""};
TVector<TString> good(canonic, canonic + 5);
@@ -187,7 +187,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
TestDelimiterOnRange<TContainerConsumer>(good, data.data(), data.end(), delim);
}
- Y_UNIT_TEST(TestWideStringDelimiter) {
+ Y_UNIT_TEST(TestWideStringDelimiter) {
TUtf16String data(u"qw ab qwababcab");
TUtf16String canonic[] = {u"qw ", u" qw", TUtf16String(), u"c", TUtf16String()};
TVector<TUtf16String> good(canonic, canonic + 5);
@@ -198,7 +198,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
TestDelimiterOnRange<TContainerConsumer>(good, data.data(), data.end(), delim);
}
- Y_UNIT_TEST(TestCharSetDelimiter) {
+ Y_UNIT_TEST(TestCharSetDelimiter) {
TString data("qw ab qwababccab");
TString canonic[] = {"q", " ab q", "abab", "", "ab"};
TVector<TString> good(canonic, canonic + 5);
@@ -208,7 +208,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
TestDelimiterOnRange<TContainerConsumer>(good, data.data(), data.end(), delim);
}
- Y_UNIT_TEST(TestWideSetDelimiter) {
+ Y_UNIT_TEST(TestWideSetDelimiter) {
TUtf16String data(u"qw ab qwababccab");
TUtf16String canonic[] = {u"q", u" ab q", u"abab", TUtf16String(), u"ab"};
TVector<TUtf16String> good(canonic, canonic + 5);
@@ -218,7 +218,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
TestDelimiterOnString<TContainerConsumer>(good, data.data(), delim);
}
- Y_UNIT_TEST(TestWideSetDelimiterRange) {
+ Y_UNIT_TEST(TestWideSetDelimiterRange) {
TUtf16String data(u"qw ab qwababccab");
TUtf16String canonic[] = {u"q", u" ab q", u"abab", TUtf16String(), u"ab"};
TVector<TUtf16String> good(1);
@@ -237,7 +237,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
Cmp(good, test);
}
- Y_UNIT_TEST(TestSplit) {
+ Y_UNIT_TEST(TestSplit) {
TString data("qw ab qwababcba");
TString canonic[] = {"qw ", " qw", "c"};
TVector<TString> good(canonic, canonic + 3);
@@ -251,7 +251,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
Cmp(good, test1);
}
- Y_UNIT_TEST(ConvenientSplitTest) {
+ Y_UNIT_TEST(ConvenientSplitTest) {
TString data("abc 22 33.5 xyz");
TString str;
int num1 = 0;
@@ -264,7 +264,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
UNIT_ASSERT_VALUES_EQUAL(strBuf, "xyz");
}
- Y_UNIT_TEST(ConvenientSplitTestWithMaybe) {
+ Y_UNIT_TEST(ConvenientSplitTestWithMaybe) {
TString data("abc 42");
TString str;
TMaybe<double> num2 = 1;
@@ -277,7 +277,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
UNIT_ASSERT(!maybe);
}
- Y_UNIT_TEST(ConvenientSplitTestExceptions) {
+ Y_UNIT_TEST(ConvenientSplitTestExceptions) {
TString data("abc 22 33");
TString s1, s2, s3, s4;
@@ -286,7 +286,7 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
UNIT_ASSERT_EXCEPTION(Split(data, ' ', s1, s2, s3, s4), yexception);
}
- Y_UNIT_TEST(ConvenientSplitTestMaybeExceptions) {
+ Y_UNIT_TEST(ConvenientSplitTestMaybeExceptions) {
TString data("abc 22 33");
TString s1, s2;
TMaybe<TString> m1, m2;
diff --git a/util/string/strip_ut.cpp b/util/string/strip_ut.cpp
index 663b648a21..d1029d1498 100644
--- a/util/string/strip_ut.cpp
+++ b/util/string/strip_ut.cpp
@@ -4,8 +4,8 @@
#include <util/charset/wide.h>
-Y_UNIT_TEST_SUITE(TStripStringTest) {
- Y_UNIT_TEST(TestStrip) {
+Y_UNIT_TEST_SUITE(TStripStringTest) {
+ Y_UNIT_TEST(TestStrip) {
struct TTest {
const char* Str;
const char* StripLeftRes;
@@ -26,25 +26,25 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
{"a c", "a c", "a c", "a c"},
};
- for (const auto& test : tests) {
+ for (const auto& test : tests) {
TString inputStr(test.Str);
TString s;
Strip(inputStr, s);
- UNIT_ASSERT_EQUAL(s, test.StripRes);
+ UNIT_ASSERT_EQUAL(s, test.StripRes);
- UNIT_ASSERT_EQUAL(StripString(inputStr), test.StripRes);
- UNIT_ASSERT_EQUAL(StripStringLeft(inputStr), test.StripLeftRes);
- UNIT_ASSERT_EQUAL(StripStringRight(inputStr), test.StripRightRes);
+ UNIT_ASSERT_EQUAL(StripString(inputStr), test.StripRes);
+ UNIT_ASSERT_EQUAL(StripStringLeft(inputStr), test.StripLeftRes);
+ UNIT_ASSERT_EQUAL(StripStringRight(inputStr), test.StripRightRes);
- TStringBuf inputStrBuf(test.Str);
- UNIT_ASSERT_EQUAL(StripString(inputStrBuf), test.StripRes);
- UNIT_ASSERT_EQUAL(StripStringLeft(inputStrBuf), test.StripLeftRes);
- UNIT_ASSERT_EQUAL(StripStringRight(inputStrBuf), test.StripRightRes);
+ TStringBuf inputStrBuf(test.Str);
+ UNIT_ASSERT_EQUAL(StripString(inputStrBuf), test.StripRes);
+ UNIT_ASSERT_EQUAL(StripStringLeft(inputStrBuf), test.StripLeftRes);
+ UNIT_ASSERT_EQUAL(StripStringRight(inputStrBuf), test.StripRightRes);
};
}
- Y_UNIT_TEST(TestCustomStrip) {
+ Y_UNIT_TEST(TestCustomStrip) {
struct TTest {
const char* Str;
const char* Result;
@@ -56,14 +56,14 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
{"012//", "012"},
};
- for (auto test : tests) {
+ for (auto test : tests) {
UNIT_ASSERT_EQUAL(
StripString(TString(test.Str), EqualsStripAdapter('/')),
- test.Result);
+ test.Result);
};
}
- Y_UNIT_TEST(TestCustomStripLeftRight) {
+ Y_UNIT_TEST(TestCustomStripLeftRight) {
struct TTest {
const char* Str;
const char* ResultLeft;
@@ -76,30 +76,30 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
{"012//", "012//", "012"},
};
- for (const auto& test : tests) {
+ for (const auto& test : tests) {
UNIT_ASSERT_EQUAL(
StripStringLeft(TString(test.Str), EqualsStripAdapter('/')),
- test.ResultLeft);
+ test.ResultLeft);
UNIT_ASSERT_EQUAL(
StripStringRight(TString(test.Str), EqualsStripAdapter('/')),
- test.ResultRight);
+ test.ResultRight);
};
}
- Y_UNIT_TEST(TestNullStringStrip) {
- TStringBuf nullString(nullptr, nullptr);
+ Y_UNIT_TEST(TestNullStringStrip) {
+ TStringBuf nullString(nullptr, nullptr);
UNIT_ASSERT_EQUAL(
StripString(nullString),
TString());
}
- Y_UNIT_TEST(TestWtrokaStrip) {
+ Y_UNIT_TEST(TestWtrokaStrip) {
UNIT_ASSERT_EQUAL(StripString(TWtringBuf(u" abc ")), u"abc");
UNIT_ASSERT_EQUAL(StripStringLeft(TWtringBuf(u" abc ")), u"abc ");
UNIT_ASSERT_EQUAL(StripStringRight(TWtringBuf(u" abc ")), u" abc");
}
- Y_UNIT_TEST(TestWtrokaCustomStrip) {
+ Y_UNIT_TEST(TestWtrokaCustomStrip) {
UNIT_ASSERT_EQUAL(
StripString(
TWtringBuf(u"/abc/"),
@@ -107,7 +107,7 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
u"abc");
}
- Y_UNIT_TEST(TestCollapse) {
+ Y_UNIT_TEST(TestCollapse) {
TString s;
Collapse(TString(" 123 456 "), s);
UNIT_ASSERT(s == " 123 456 ");
@@ -124,7 +124,7 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
#endif
}
- Y_UNIT_TEST(TestCollapseText) {
+ Y_UNIT_TEST(TestCollapseText) {
TString abs1("Very long description string written in unknown language.");
TString abs2(abs1);
TString abs3(abs1);
diff --git a/util/string/subst.cpp b/util/string/subst.cpp
index 8daef0708b..b2df328dc1 100644
--- a/util/string/subst.cpp
+++ b/util/string/subst.cpp
@@ -1,200 +1,200 @@
#include "subst.h"
-
-#include <util/generic/strbuf.h>
-#include <util/generic/string.h>
-#include <util/system/compiler.h>
-
-#include <string>
-#include <type_traits>
-
-// a bit of template magic (to be fast and unreadable)
-template <class TStringType, class TTo, bool Main>
-static Y_FORCE_INLINE void MoveBlock(typename TStringType::value_type* ptr, size_t& srcPos, size_t& dstPos, const size_t off, const TTo to, const size_t toSize) {
- const size_t unchangedSize = off - srcPos;
- if (dstPos < srcPos) {
- for (size_t i = 0; i < unchangedSize; ++i) {
- ptr[dstPos++] = ptr[srcPos++];
- }
- } else {
- dstPos += unchangedSize;
- srcPos += unchangedSize;
- }
-
- if (Main) {
- for (size_t i = 0; i < toSize; ++i) {
- ptr[dstPos++] = to[i];
- }
- }
-}
-
-template <typename T, typename U>
-static bool IsIntersect(const T& a, const U& b) noexcept {
- if (b.data() < a.data()) {
- return IsIntersect(b, a);
- }
-
- return !a.empty() && !b.empty() &&
- ((a.data() <= b.data() && b.data() < a.data() + a.size()) ||
- (a.data() < b.data() + b.size() && b.data() + b.size() <= a.data() + a.size()));
-}
-
-/**
- * Replaces all occurences of substring @c from in string @c s to string @c to.
- * Uses two separate implementations (inplace for shrink and append for grow case)
- * See IGNIETFERRO-394
- **/
+
+#include <util/generic/strbuf.h>
+#include <util/generic/string.h>
+#include <util/system/compiler.h>
+
+#include <string>
+#include <type_traits>
+
+// a bit of template magic (to be fast and unreadable)
+template <class TStringType, class TTo, bool Main>
+static Y_FORCE_INLINE void MoveBlock(typename TStringType::value_type* ptr, size_t& srcPos, size_t& dstPos, const size_t off, const TTo to, const size_t toSize) {
+ const size_t unchangedSize = off - srcPos;
+ if (dstPos < srcPos) {
+ for (size_t i = 0; i < unchangedSize; ++i) {
+ ptr[dstPos++] = ptr[srcPos++];
+ }
+ } else {
+ dstPos += unchangedSize;
+ srcPos += unchangedSize;
+ }
+
+ if (Main) {
+ for (size_t i = 0; i < toSize; ++i) {
+ ptr[dstPos++] = to[i];
+ }
+ }
+}
+
+template <typename T, typename U>
+static bool IsIntersect(const T& a, const U& b) noexcept {
+ if (b.data() < a.data()) {
+ return IsIntersect(b, a);
+ }
+
+ return !a.empty() && !b.empty() &&
+ ((a.data() <= b.data() && b.data() < a.data() + a.size()) ||
+ (a.data() < b.data() + b.size() && b.data() + b.size() <= a.data() + a.size()));
+}
+
+/**
+ * Replaces all occurences of substring @c from in string @c s to string @c to.
+ * Uses two separate implementations (inplace for shrink and append for grow case)
+ * See IGNIETFERRO-394
+ **/
template <class TStringType, typename TStringViewType = TBasicStringBuf<typename TStringType::value_type>>
-static inline size_t SubstGlobalImpl(TStringType& s, const TStringViewType from, const TStringViewType to, size_t fromPos = 0) {
+static inline size_t SubstGlobalImpl(TStringType& s, const TStringViewType from, const TStringViewType to, size_t fromPos = 0) {
if (from.empty()) {
- return 0;
- }
-
- Y_ASSERT(!IsIntersect(s, from));
- Y_ASSERT(!IsIntersect(s, to));
-
- const size_t fromSize = from.size();
- const size_t toSize = to.size();
- size_t replacementsCount = 0;
- size_t off = fromPos;
- size_t srcPos = 0;
-
- if (toSize > fromSize) {
- // string will grow: append to another string
- TStringType result;
- for (; (off = TStringViewType(s).find(from, off)) != TStringType::npos; off += fromSize) {
- if (!replacementsCount) {
- // first replacement occured, we can prepare result string
- result.reserve(s.size() + s.size() / 3);
- }
- result.append(s.begin() + srcPos, s.begin() + off);
+ return 0;
+ }
+
+ Y_ASSERT(!IsIntersect(s, from));
+ Y_ASSERT(!IsIntersect(s, to));
+
+ const size_t fromSize = from.size();
+ const size_t toSize = to.size();
+ size_t replacementsCount = 0;
+ size_t off = fromPos;
+ size_t srcPos = 0;
+
+ if (toSize > fromSize) {
+ // string will grow: append to another string
+ TStringType result;
+ for (; (off = TStringViewType(s).find(from, off)) != TStringType::npos; off += fromSize) {
+ if (!replacementsCount) {
+ // first replacement occured, we can prepare result string
+ result.reserve(s.size() + s.size() / 3);
+ }
+ result.append(s.begin() + srcPos, s.begin() + off);
result.append(to.data(), to.size());
- srcPos = off + fromSize;
- ++replacementsCount;
- }
- if (replacementsCount) {
- // append tail
- result.append(s.begin() + srcPos, s.end());
- s = std::move(result);
- }
- return replacementsCount;
- }
-
- // string will not grow: use inplace algo
- size_t dstPos = 0;
+ srcPos = off + fromSize;
+ ++replacementsCount;
+ }
+ if (replacementsCount) {
+ // append tail
+ result.append(s.begin() + srcPos, s.end());
+ s = std::move(result);
+ }
+ return replacementsCount;
+ }
+
+ // string will not grow: use inplace algo
+ size_t dstPos = 0;
typename TStringType::value_type* ptr = &*s.begin();
- for (; (off = TStringViewType(s).find(from, off)) != TStringType::npos; off += fromSize) {
- Y_ASSERT(dstPos <= srcPos);
- MoveBlock<TStringType, TStringViewType, true>(ptr, srcPos, dstPos, off, to, toSize);
- srcPos = off + fromSize;
- ++replacementsCount;
- }
-
- if (replacementsCount) {
- // append tail
- MoveBlock<TStringType, TStringViewType, false>(ptr, srcPos, dstPos, s.size(), to, toSize);
- s.resize(dstPos);
- }
- return replacementsCount;
-}
-
-/// Replaces all occurences of the 'from' symbol in a string to the 'to' symbol.
-template <class TStringType>
-inline size_t SubstCharGlobalImpl(TStringType& s, typename TStringType::value_type from, typename TStringType::value_type to, size_t fromPos = 0) {
- if (fromPos >= s.size()) {
- return 0;
- }
-
- size_t result = 0;
- fromPos = s.find(from, fromPos);
-
- // s.begin() might cause memory copying, so call it only if needed
- if (fromPos != TStringType::npos) {
+ for (; (off = TStringViewType(s).find(from, off)) != TStringType::npos; off += fromSize) {
+ Y_ASSERT(dstPos <= srcPos);
+ MoveBlock<TStringType, TStringViewType, true>(ptr, srcPos, dstPos, off, to, toSize);
+ srcPos = off + fromSize;
+ ++replacementsCount;
+ }
+
+ if (replacementsCount) {
+ // append tail
+ MoveBlock<TStringType, TStringViewType, false>(ptr, srcPos, dstPos, s.size(), to, toSize);
+ s.resize(dstPos);
+ }
+ return replacementsCount;
+}
+
+/// Replaces all occurences of the 'from' symbol in a string to the 'to' symbol.
+template <class TStringType>
+inline size_t SubstCharGlobalImpl(TStringType& s, typename TStringType::value_type from, typename TStringType::value_type to, size_t fromPos = 0) {
+ if (fromPos >= s.size()) {
+ return 0;
+ }
+
+ size_t result = 0;
+ fromPos = s.find(from, fromPos);
+
+ // s.begin() might cause memory copying, so call it only if needed
+ if (fromPos != TStringType::npos) {
auto* it = &*s.begin() + fromPos;
- *it = to;
- ++result;
- // at this point string is copied and it's safe to use constant s.end() to iterate
+ *it = to;
+ ++result;
+ // at this point string is copied and it's safe to use constant s.end() to iterate
const auto* const sEnd = &*s.end();
- // unrolled loop goes first because it is more likely that `it` will be properly aligned
- for (const auto* const end = sEnd - (sEnd - it) % 4; it < end;) {
- if (*it == from) {
- *it = to;
- ++result;
- }
- ++it;
- if (*it == from) {
- *it = to;
- ++result;
- }
- ++it;
- if (*it == from) {
- *it = to;
- ++result;
- }
- ++it;
- if (*it == from) {
- *it = to;
- ++result;
- }
- ++it;
- }
- for (; it < sEnd; ++it) {
- if (*it == from) {
- *it = to;
- ++result;
- }
- }
- }
-
- return result;
-}
-
-/* Standard says that `char16_t` is a distinct type and has same size, signedness and alignment as
- * `std::uint_least16_t`, so we check if `char16_t` has same signedness and size as `wchar16` to be
- * sure that we can make safe casts between values of these types and pointers.
- */
-static_assert(sizeof(wchar16) == sizeof(char16_t), "");
+ // unrolled loop goes first because it is more likely that `it` will be properly aligned
+ for (const auto* const end = sEnd - (sEnd - it) % 4; it < end;) {
+ if (*it == from) {
+ *it = to;
+ ++result;
+ }
+ ++it;
+ if (*it == from) {
+ *it = to;
+ ++result;
+ }
+ ++it;
+ if (*it == from) {
+ *it = to;
+ ++result;
+ }
+ ++it;
+ if (*it == from) {
+ *it = to;
+ ++result;
+ }
+ ++it;
+ }
+ for (; it < sEnd; ++it) {
+ if (*it == from) {
+ *it = to;
+ ++result;
+ }
+ }
+ }
+
+ return result;
+}
+
+/* Standard says that `char16_t` is a distinct type and has same size, signedness and alignment as
+ * `std::uint_least16_t`, so we check if `char16_t` has same signedness and size as `wchar16` to be
+ * sure that we can make safe casts between values of these types and pointers.
+ */
+static_assert(sizeof(wchar16) == sizeof(char16_t), "");
static_assert(sizeof(wchar32) == sizeof(char32_t), "");
-static_assert(std::is_unsigned<wchar16>::value == std::is_unsigned<char16_t>::value, "");
+static_assert(std::is_unsigned<wchar16>::value == std::is_unsigned<char16_t>::value, "");
static_assert(std::is_unsigned<wchar32>::value == std::is_unsigned<char32_t>::value, "");
-
-size_t SubstGlobal(TString& text, const TStringBuf what, const TStringBuf with, size_t from) {
- return SubstGlobalImpl(text, what, with, from);
-}
-
-size_t SubstGlobal(std::string& text, const TStringBuf what, const TStringBuf with, size_t from) {
- return SubstGlobalImpl(text, what, with, from);
-}
-
-size_t SubstGlobal(TUtf16String& text, const TWtringBuf what, const TWtringBuf with, size_t from) {
- return SubstGlobalImpl(text, what, with, from);
-}
-
+
+size_t SubstGlobal(TString& text, const TStringBuf what, const TStringBuf with, size_t from) {
+ return SubstGlobalImpl(text, what, with, from);
+}
+
+size_t SubstGlobal(std::string& text, const TStringBuf what, const TStringBuf with, size_t from) {
+ return SubstGlobalImpl(text, what, with, from);
+}
+
+size_t SubstGlobal(TUtf16String& text, const TWtringBuf what, const TWtringBuf with, size_t from) {
+ return SubstGlobalImpl(text, what, with, from);
+}
+
size_t SubstGlobal(TUtf32String& text, const TUtf32StringBuf what, const TUtf32StringBuf with, size_t from) {
return SubstGlobalImpl(text, what, with, from);
}
-size_t SubstGlobal(std::u16string& text, const TWtringBuf what, const TWtringBuf with, size_t from) {
+size_t SubstGlobal(std::u16string& text, const TWtringBuf what, const TWtringBuf with, size_t from) {
return SubstGlobalImpl(text,
std::u16string_view(reinterpret_cast<const char16_t*>(what.data()), what.size()),
std::u16string_view(reinterpret_cast<const char16_t*>(with.data()), with.size()),
from);
-}
-
-size_t SubstGlobal(TString& text, char what, char with, size_t from) {
- return SubstCharGlobalImpl(text, what, with, from);
-}
-
-size_t SubstGlobal(std::string& text, char what, char with, size_t from) {
- return SubstCharGlobalImpl(text, what, with, from);
-}
-
-size_t SubstGlobal(TUtf16String& text, wchar16 what, wchar16 with, size_t from) {
- return SubstCharGlobalImpl(text, (char16_t)what, (char16_t)with, from);
-}
-
-size_t SubstGlobal(std::u16string& text, wchar16 what, wchar16 with, size_t from) {
- return SubstCharGlobalImpl(text, (char16_t)what, (char16_t)with, from);
-}
+}
+
+size_t SubstGlobal(TString& text, char what, char with, size_t from) {
+ return SubstCharGlobalImpl(text, what, with, from);
+}
+
+size_t SubstGlobal(std::string& text, char what, char with, size_t from) {
+ return SubstCharGlobalImpl(text, what, with, from);
+}
+
+size_t SubstGlobal(TUtf16String& text, wchar16 what, wchar16 with, size_t from) {
+ return SubstCharGlobalImpl(text, (char16_t)what, (char16_t)with, from);
+}
+
+size_t SubstGlobal(std::u16string& text, wchar16 what, wchar16 with, size_t from) {
+ return SubstCharGlobalImpl(text, (char16_t)what, (char16_t)with, from);
+}
size_t SubstGlobal(TUtf32String& text, wchar32 what, wchar32 with, size_t from) {
return SubstCharGlobalImpl(text, (char32_t)what, (char32_t)with, from);
diff --git a/util/string/subst.h b/util/string/subst.h
index 32a2789801..45b622fbef 100644
--- a/util/string/subst.h
+++ b/util/string/subst.h
@@ -1,44 +1,44 @@
#pragma once
-#include <util/generic/fwd.h>
+#include <util/generic/fwd.h>
-#include <stlfwd>
+#include <stlfwd>
-/* Replace all occurences of substring `what` with string `with` starting from position `from`.
- *
- * @param text String to modify.
- * @param what Substring to replace.
- * @param with Substring to use as replacement.
- * @param from Position at with to start replacement.
- *
- * @return Number of replacements occured.
- */
-size_t SubstGlobal(TString& text, TStringBuf what, TStringBuf with, size_t from = 0);
-size_t SubstGlobal(std::string& text, TStringBuf what, TStringBuf with, size_t from = 0);
-size_t SubstGlobal(TUtf16String& text, TWtringBuf what, TWtringBuf with, size_t from = 0);
-size_t SubstGlobal(std::u16string& text, TWtringBuf what, TWtringBuf with, size_t from = 0);
+/* Replace all occurences of substring `what` with string `with` starting from position `from`.
+ *
+ * @param text String to modify.
+ * @param what Substring to replace.
+ * @param with Substring to use as replacement.
+ * @param from Position at with to start replacement.
+ *
+ * @return Number of replacements occured.
+ */
+size_t SubstGlobal(TString& text, TStringBuf what, TStringBuf with, size_t from = 0);
+size_t SubstGlobal(std::string& text, TStringBuf what, TStringBuf with, size_t from = 0);
+size_t SubstGlobal(TUtf16String& text, TWtringBuf what, TWtringBuf with, size_t from = 0);
+size_t SubstGlobal(std::u16string& text, TWtringBuf what, TWtringBuf with, size_t from = 0);
size_t SubstGlobal(TUtf32String& text, TUtf32StringBuf what, TUtf32StringBuf with, size_t from = 0);
-/* Replace all occurences of character `what` with character `with` starting from position `from`.
- *
- * @param text String to modify.
- * @param what Character to replace.
- * @param with Character to use as replacement.
- * @param from Position at with to start replacement.
- *
- * @return Number of replacements occured.
- */
-size_t SubstGlobal(TString& text, char what, char with, size_t from = 0);
-size_t SubstGlobal(std::string& text, char what, char with, size_t from = 0);
-size_t SubstGlobal(TUtf16String& text, wchar16 what, wchar16 with, size_t from = 0);
-size_t SubstGlobal(std::u16string& text, wchar16 what, wchar16 with, size_t from = 0);
+/* Replace all occurences of character `what` with character `with` starting from position `from`.
+ *
+ * @param text String to modify.
+ * @param what Character to replace.
+ * @param with Character to use as replacement.
+ * @param from Position at with to start replacement.
+ *
+ * @return Number of replacements occured.
+ */
+size_t SubstGlobal(TString& text, char what, char with, size_t from = 0);
+size_t SubstGlobal(std::string& text, char what, char with, size_t from = 0);
+size_t SubstGlobal(TUtf16String& text, wchar16 what, wchar16 with, size_t from = 0);
+size_t SubstGlobal(std::u16string& text, wchar16 what, wchar16 with, size_t from = 0);
size_t SubstGlobal(TUtf32String& text, wchar32 what, wchar32 with, size_t from = 0);
-// TODO(yazevnul):
-// - rename `SubstGlobal` to `ReplaceAll` for convenience
+// TODO(yazevnul):
+// - rename `SubstGlobal` to `ReplaceAll` for convenience
// - add `SubstGlobalCopy(TStringBuf)` for convenience
-// - add `RemoveAll(text, what, from)` as a shortcut for `SubstGlobal(text, what, "", from)`
-// - rename file to `replace.h`
+// - add `RemoveAll(text, what, from)` as a shortcut for `SubstGlobal(text, what, "", from)`
+// - rename file to `replace.h`
/* Replace all occurences of substring or character `what` with string or character `with` starting from position `from`, and return result string.
*
diff --git a/util/string/subst_ut.cpp b/util/string/subst_ut.cpp
index fc88469ceb..21eccef779 100644
--- a/util/string/subst_ut.cpp
+++ b/util/string/subst_ut.cpp
@@ -4,7 +4,7 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TStringSubst) {
+Y_UNIT_TEST_SUITE(TStringSubst) {
static const size_t MIN_FROM_CTX = 4;
static const TVector<TString> ALL_FROM{TString("F"), TString("FF")};
static const TVector<TString> ALL_TO{TString(""), TString("T"), TString("TT"), TString("TTT")};
@@ -24,7 +24,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
}
}
- Y_UNIT_TEST(TestSubstGlobalNoSubstA) {
+ Y_UNIT_TEST(TestSubstGlobalNoSubstA) {
for (const auto& from : ALL_FROM) {
const size_t fromSz = from.size();
const size_t minSz = fromSz;
@@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
}
}
- Y_UNIT_TEST(TestSubstGlobalNoSubstB) {
+ Y_UNIT_TEST(TestSubstGlobalNoSubstB) {
for (const auto& from : ALL_FROM) {
const size_t fromSz = from.size();
const size_t minSz = fromSz;
@@ -103,23 +103,23 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
}
}
- Y_UNIT_TEST(TestSubstGlobalSubst1) {
+ Y_UNIT_TEST(TestSubstGlobalSubst1) {
DoTestSubstGlobal(1);
}
- Y_UNIT_TEST(TestSubstGlobalSubst2) {
+ Y_UNIT_TEST(TestSubstGlobalSubst2) {
DoTestSubstGlobal(2);
}
- Y_UNIT_TEST(TestSubstGlobalSubst3) {
+ Y_UNIT_TEST(TestSubstGlobalSubst3) {
DoTestSubstGlobal(3);
}
- Y_UNIT_TEST(TestSubstGlobalSubst4) {
+ Y_UNIT_TEST(TestSubstGlobalSubst4) {
DoTestSubstGlobal(4);
}
- Y_UNIT_TEST(TestSubstGlobalOld) {
+ Y_UNIT_TEST(TestSubstGlobalOld) {
TString s;
s = "aaa";
SubstGlobal(s, "a", "bb");
@@ -160,7 +160,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
UNIT_ASSERT_EQUAL(s10, TString("Москва Париж"));
}
- Y_UNIT_TEST(TestSubstCharGlobal) {
+ Y_UNIT_TEST(TestSubstCharGlobal) {
TUtf16String w = u"abcdabcd";
SubstGlobal(w, wchar16('b'), wchar16('B'), 3);
UNIT_ASSERT_EQUAL(w, u"abcdaBcd");
@@ -180,74 +180,74 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
UNIT_ASSERT_EQUAL(s2, TString("abb"));
}
- Y_UNIT_TEST(TestSubstStdString) {
+ Y_UNIT_TEST(TestSubstStdString) {
std::string s = "aaa";
SubstGlobal(s, "a", "b", 1);
UNIT_ASSERT_EQUAL(s, "abb");
}
-
+
Y_UNIT_TEST(TestSubstStdStringRet) {
const std::string s1 = "aaa";
const std::string s2 = SubstGlobalCopy(s1, "a", "b", 1);
UNIT_ASSERT_EQUAL(s2, "abb");
}
- Y_UNIT_TEST(TestSubstGlobalChar) {
- {
+ Y_UNIT_TEST(TestSubstGlobalChar) {
+ {
const TString s = "a";
const TString st = "b";
TString ss = s;
- UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
- UNIT_ASSERT_VALUES_EQUAL(st, ss);
- }
- {
+ UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
+ UNIT_ASSERT_VALUES_EQUAL(st, ss);
+ }
+ {
const TString s = "aa";
const TString st = "bb";
TString ss = s;
- UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
- UNIT_ASSERT_VALUES_EQUAL(st, ss);
- }
- {
+ UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
+ UNIT_ASSERT_VALUES_EQUAL(st, ss);
+ }
+ {
const TString s = "aaa";
const TString st = "bbb";
TString ss = s;
- UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
- UNIT_ASSERT_VALUES_EQUAL(st, ss);
- }
- {
+ UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
+ UNIT_ASSERT_VALUES_EQUAL(st, ss);
+ }
+ {
const TString s = "aaaa";
const TString st = "bbbb";
TString ss = s;
- UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
- UNIT_ASSERT_VALUES_EQUAL(st, ss);
- }
- {
+ UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
+ UNIT_ASSERT_VALUES_EQUAL(st, ss);
+ }
+ {
const TString s = "aaaaa";
const TString st = "bbbbb";
TString ss = s;
- UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
- UNIT_ASSERT_VALUES_EQUAL(st, ss);
- }
- {
+ UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
+ UNIT_ASSERT_VALUES_EQUAL(st, ss);
+ }
+ {
const TString s = "aaaaaa";
const TString st = "bbbbbb";
TString ss = s;
- UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
- UNIT_ASSERT_VALUES_EQUAL(st, ss);
- }
- {
+ UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
+ UNIT_ASSERT_VALUES_EQUAL(st, ss);
+ }
+ {
const TString s = "aaaaaaa";
const TString st = "bbbbbbb";
TString ss = s;
- UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
- UNIT_ASSERT_VALUES_EQUAL(st, ss);
- }
- {
+ UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
+ UNIT_ASSERT_VALUES_EQUAL(st, ss);
+ }
+ {
const TString s = "aaaaaaaa";
const TString st = "bbbbbbbb";
TString ss = s;
- UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
- UNIT_ASSERT_VALUES_EQUAL(st, ss);
- }
- }
+ UNIT_ASSERT_VALUES_EQUAL(s.size(), SubstGlobal(ss, 'a', 'b'));
+ UNIT_ASSERT_VALUES_EQUAL(st, ss);
+ }
+ }
}
diff --git a/util/string/type.cpp b/util/string/type.cpp
index 668b445afa..49671c02c2 100644
--- a/util/string/type.cpp
+++ b/util/string/type.cpp
@@ -24,11 +24,11 @@ static bool IsNumberT(const TStringType& s) noexcept {
return std::all_of(s.begin(), s.end(), IsAsciiDigit<typename TStringType::value_type>);
}
-bool IsNumber(const TStringBuf s) noexcept {
+bool IsNumber(const TStringBuf s) noexcept {
return IsNumberT(s);
}
-bool IsNumber(const TWtringBuf s) noexcept {
+bool IsNumber(const TWtringBuf s) noexcept {
return IsNumberT(s);
}
@@ -41,11 +41,11 @@ static bool IsHexNumberT(const TStringType& s) noexcept {
return std::all_of(s.begin(), s.end(), IsAsciiHex<typename TStringType::value_type>);
}
-bool IsHexNumber(const TStringBuf s) noexcept {
+bool IsHexNumber(const TStringBuf s) noexcept {
return IsHexNumberT(s);
}
-bool IsHexNumber(const TWtringBuf s) noexcept {
+bool IsHexNumber(const TWtringBuf s) noexcept {
return IsHexNumberT(s);
}
diff --git a/util/string/type_ut.cpp b/util/string/type_ut.cpp
index 7f342a8e24..03e7af62bd 100644
--- a/util/string/type_ut.cpp
+++ b/util/string/type_ut.cpp
@@ -4,15 +4,15 @@
#include <util/charset/wide.h>
-Y_UNIT_TEST_SUITE(TStringClassify) {
- Y_UNIT_TEST(TestIsSpace) {
+Y_UNIT_TEST_SUITE(TStringClassify) {
+ Y_UNIT_TEST(TestIsSpace) {
UNIT_ASSERT_EQUAL(IsSpace(" "), true);
UNIT_ASSERT_EQUAL(IsSpace("\t\r\n"), true);
UNIT_ASSERT_EQUAL(IsSpace(""), false);
UNIT_ASSERT_EQUAL(IsSpace(" a"), false);
}
- Y_UNIT_TEST(TestIsTrue) {
+ Y_UNIT_TEST(TestIsTrue) {
UNIT_ASSERT(IsTrue("1"));
UNIT_ASSERT(IsTrue("yes"));
UNIT_ASSERT(IsTrue("YeS"));
@@ -26,7 +26,7 @@ Y_UNIT_TEST_SUITE(TStringClassify) {
UNIT_ASSERT(!IsTrue("foobar"));
}
- Y_UNIT_TEST(TestIsFalse) {
+ Y_UNIT_TEST(TestIsFalse) {
UNIT_ASSERT(IsFalse("0"));
UNIT_ASSERT(IsFalse("no"));
UNIT_ASSERT(IsFalse("off"));
@@ -39,7 +39,7 @@ Y_UNIT_TEST_SUITE(TStringClassify) {
UNIT_ASSERT(!IsFalse("foobar"));
}
- Y_UNIT_TEST(TestIsNumber) {
+ Y_UNIT_TEST(TestIsNumber) {
UNIT_ASSERT(IsNumber("0"));
UNIT_ASSERT(IsNumber("12345678901234567890"));
UNIT_ASSERT(!IsNumber("1234567890a"));
@@ -54,7 +54,7 @@ Y_UNIT_TEST_SUITE(TStringClassify) {
UNIT_ASSERT(!IsNumber(u"foobar"));
}
- Y_UNIT_TEST(TestIsHexNumber) {
+ Y_UNIT_TEST(TestIsHexNumber) {
UNIT_ASSERT(IsHexNumber("0"));
UNIT_ASSERT(IsHexNumber("aaaadddAAAAA"));
UNIT_ASSERT(IsHexNumber("0123456789ABCDEFabcdef"));
diff --git a/util/string/util.h b/util/string/util.h
index 4c9732fcaf..0d77a5042b 100644
--- a/util/string/util.h
+++ b/util/string/util.h
@@ -132,7 +132,7 @@ public:
/// strsep + remember character that was destroyed
char* sep(char*& s, char& sep_char) const {
if (!s)
- return nullptr;
+ return nullptr;
char* ret = s;
char* next = brk(ret);
if (*next) {
@@ -141,7 +141,7 @@ public:
s = next + 1;
} else {
sep_char = 0;
- s = nullptr;
+ s = nullptr;
}
return ret;
}
diff --git a/util/string/util_ut.cpp b/util/string/util_ut.cpp
index 706b63cfdc..18a2d8e195 100644
--- a/util/string/util_ut.cpp
+++ b/util/string/util_ut.cpp
@@ -20,7 +20,7 @@ public:
UNIT_ASSERT_EQUAL(strcmp(rul.sep(s1), ""), 0);
UNIT_ASSERT_EQUAL(strcmp(rul.sep(s1), "%^&"), 0);
UNIT_ASSERT_EQUAL(strcmp(rul.sep(s1), "+-"), 0);
- UNIT_ASSERT_EQUAL(rul.sep(s1), nullptr);
+ UNIT_ASSERT_EQUAL(rul.sep(s1), nullptr);
}
void TestRemoveAll() {
@@ -35,7 +35,7 @@ public:
{"hello world", 'x', "hello world"},
};
- for (const T* t = tests; t != std::end(tests); ++t) {
+ for (const T* t = tests; t != std::end(tests); ++t) {
TString str(t->Str);
RemoveAll(str, t->Ch);
UNIT_ASSERT_EQUAL(t->Result, str);
diff --git a/util/string/vector.h b/util/string/vector.h
index fce7e4ab00..e36c348bbe 100644
--- a/util/string/vector.h
+++ b/util/string/vector.h
@@ -1,14 +1,14 @@
#pragma once
-#include "cast.h"
+#include "cast.h"
#include "split.h"
-
+
#include <util/generic/map.h>
-#include <util/generic/strbuf.h>
+#include <util/generic/strbuf.h>
#include <util/generic/string.h>
#include <util/generic/vector.h>
#include <util/string/cast.h>
-#include <util/system/yassert.h>
+#include <util/system/yassert.h>
#define KEEP_EMPTY_TOKENS 0x01
@@ -120,8 +120,8 @@ inline TString JoinVectorIntoString(const TVector<T>& v, size_t index, size_t co
TUtf16String JoinStrings(const TVector<TUtf16String>& v, const TWtringBuf delim);
TUtf16String JoinStrings(const TVector<TUtf16String>& v, size_t index, size_t count, const TWtringBuf delim);
-//! Converts vector of strings to vector of type T variables
-template <typename T, typename TStringType>
+//! Converts vector of strings to vector of type T variables
+template <typename T, typename TStringType>
TVector<T> Scan(const TVector<TStringType>& input) {
TVector<T> output;
output.reserve(input.size());
diff --git a/util/string/vector_ut.cpp b/util/string/vector_ut.cpp
index 9c4222f9ee..817120f268 100644
--- a/util/string/vector_ut.cpp
+++ b/util/string/vector_ut.cpp
@@ -4,14 +4,14 @@
#include "cast.h"
#include "vector.h"
-Y_UNIT_TEST_SUITE(TStringJoinTest) {
- Y_UNIT_TEST(Test1) {
+Y_UNIT_TEST_SUITE(TStringJoinTest) {
+ Y_UNIT_TEST(Test1) {
TVector<TUtf16String> v;
UNIT_ASSERT_EQUAL(JoinStrings(v, ToWtring("")), ToWtring(""));
}
- Y_UNIT_TEST(Test2) {
+ Y_UNIT_TEST(Test2) {
TVector<TUtf16String> v;
v.push_back(ToWtring("1"));
@@ -20,7 +20,7 @@ Y_UNIT_TEST_SUITE(TStringJoinTest) {
UNIT_ASSERT_EQUAL(JoinStrings(v, ToWtring(" ")), ToWtring("1 2"));
}
- Y_UNIT_TEST(Test3) {
+ Y_UNIT_TEST(Test3) {
TVector<TUtf16String> v;
v.push_back(ToWtring("1"));
@@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(TStringJoinTest) {
UNIT_ASSERT_EQUAL(JoinStrings(v, 1, 10, ToWtring(" ")), ToWtring("2"));
}
- Y_UNIT_TEST(TestJoinWStrings) {
+ Y_UNIT_TEST(TestJoinWStrings) {
const TUtf16String str = u"Яндекс";
const TVector<TUtf16String> v(1, str);
diff --git a/util/system/atexit.cpp b/util/system/atexit.cpp
index 2ff9284f76..74fb10b6b1 100644
--- a/util/system/atexit.cpp
+++ b/util/system/atexit.cpp
@@ -42,7 +42,7 @@ namespace {
while (Items_) {
auto c = Items_.top();
- Y_ASSERT(c);
+ Y_ASSERT(c);
Items_.pop();
diff --git a/util/system/atomic_ops.h b/util/system/atomic_ops.h
index ec2e0959e2..76766b4a0a 100644
--- a/util/system/atomic_ops.h
+++ b/util/system/atomic_ops.h
@@ -22,7 +22,7 @@ struct TAtomicTraits {
};
template <typename T, typename TT>
-using TEnableIfCastable = std::enable_if_t<TAtomicTraits<T>::Castable, TT>;
+using TEnableIfCastable = std::enable_if_t<TAtomicTraits<T>::Castable, TT>;
template <typename T>
inline TEnableIfCastable<T, T> AtomicGet(T const volatile& target) {
diff --git a/util/system/backtrace.cpp b/util/system/backtrace.cpp
index b749957886..b77fe58fb1 100644
--- a/util/system/backtrace.cpp
+++ b/util/system/backtrace.cpp
@@ -3,7 +3,7 @@
#include "platform.h"
#include "backtrace.h"
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/stream/format.h>
#include <util/generic/array_ref.h>
#include <util/generic/string.h>
@@ -233,13 +233,13 @@ TResolvedSymbol ResolveSymbol(void* sym, char*, size_t) {
}
#endif
-void FormatBackTrace(IOutputStream* out, void* const* backtrace, size_t backtraceSize) {
+void FormatBackTrace(IOutputStream* out, void* const* backtrace, size_t backtraceSize) {
char tmpBuf[1024];
for (size_t i = 0; i < backtraceSize; ++i) {
TResolvedSymbol rs = ResolveSymbol(backtrace[i], tmpBuf, sizeof(tmpBuf));
- *out << rs.Name << "+" << ((ptrdiff_t)backtrace[i] - (ptrdiff_t)rs.NearestSymbol) << " (" << Hex((ptrdiff_t)backtrace[i], HF_ADDX) << ')' << '\n';
+ *out << rs.Name << "+" << ((ptrdiff_t)backtrace[i] - (ptrdiff_t)rs.NearestSymbol) << " (" << Hex((ptrdiff_t)backtrace[i], HF_ADDX) << ')' << '\n';
}
}
@@ -274,7 +274,7 @@ void TBackTrace::Capture() {
Size = BackTrace(Data, CAPACITY);
}
-void TBackTrace::PrintTo(IOutputStream& out) const {
+void TBackTrace::PrintTo(IOutputStream& out) const {
FormatBackTraceFn(&out, Data, Size);
}
diff --git a/util/system/backtrace.h b/util/system/backtrace.h
index d19502953d..2fce7585c3 100644
--- a/util/system/backtrace.h
+++ b/util/system/backtrace.h
@@ -3,7 +3,7 @@
#include <util/generic/fwd.h>
#include <util/system/defaults.h>
-class IOutputStream;
+class IOutputStream;
size_t BackTrace(void** p, size_t len);
@@ -14,8 +14,8 @@ struct TResolvedSymbol {
TResolvedSymbol ResolveSymbol(void* sym, char* buf, size_t len);
-void FormatBackTrace(IOutputStream* out, void* const* backtrace, size_t backtraceSize);
-void FormatBackTrace(IOutputStream* out);
+void FormatBackTrace(IOutputStream* out, void* const* backtrace, size_t backtraceSize);
+void FormatBackTrace(IOutputStream* out);
void PrintBackTrace();
using TFormatBackTraceFn = void (*)(IOutputStream*, void* const* backtrace, size_t backtraceSize);
@@ -34,7 +34,7 @@ private:
public:
TBackTrace();
void Capture();
- void PrintTo(IOutputStream&) const;
+ void PrintTo(IOutputStream&) const;
TString PrintToString() const;
size_t size() const;
const void* const* data() const;
diff --git a/util/system/backtrace_ut.cpp b/util/system/backtrace_ut.cpp
index a141308345..9b5ead71bc 100644
--- a/util/system/backtrace_ut.cpp
+++ b/util/system/backtrace_ut.cpp
@@ -3,7 +3,7 @@
#include <util/generic/array_ref.h>
#include <library/cpp/testing/unittest/registar.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
using PFunc = int (*)(void**, size_t);
diff --git a/util/system/benchmark/cpu_id/main.cpp b/util/system/benchmark/cpu_id/main.cpp
index 11f29deda8..8efe539983 100644
--- a/util/system/benchmark/cpu_id/main.cpp
+++ b/util/system/benchmark/cpu_id/main.cpp
@@ -1,51 +1,51 @@
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/system/cpu_id.h>
-
-#include <util/generic/xrange.h>
-
-#define DEFINE_BENCHMARK_PAIR(name) \
- Y_CPU_BENCHMARK(Have##name, iface) { \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- Y_DO_NOT_OPTIMIZE_AWAY(NX86::Have##name()); \
- } \
- } \
- \
- Y_CPU_BENCHMARK(CachedHave##name, iface) { \
- for (const auto i : xrange(iface.Iterations())) { \
- Y_UNUSED(i); \
- Y_DO_NOT_OPTIMIZE_AWAY(NX86::CachedHave##name()); \
- } \
- }
-
-DEFINE_BENCHMARK_PAIR(SSE)
-DEFINE_BENCHMARK_PAIR(SSE2)
-DEFINE_BENCHMARK_PAIR(SSE3)
-DEFINE_BENCHMARK_PAIR(SSSE3)
-DEFINE_BENCHMARK_PAIR(SSE41)
-DEFINE_BENCHMARK_PAIR(SSE42)
-DEFINE_BENCHMARK_PAIR(POPCNT)
-DEFINE_BENCHMARK_PAIR(BMI1)
-DEFINE_BENCHMARK_PAIR(AES)
-DEFINE_BENCHMARK_PAIR(AVX)
-DEFINE_BENCHMARK_PAIR(AVX2)
-DEFINE_BENCHMARK_PAIR(AVX512F)
-DEFINE_BENCHMARK_PAIR(AVX512DQ)
-DEFINE_BENCHMARK_PAIR(AVX512IFMA)
-DEFINE_BENCHMARK_PAIR(AVX512PF)
-DEFINE_BENCHMARK_PAIR(AVX512ER)
-DEFINE_BENCHMARK_PAIR(AVX512CD)
-DEFINE_BENCHMARK_PAIR(AVX512BW)
-DEFINE_BENCHMARK_PAIR(AVX512VL)
-DEFINE_BENCHMARK_PAIR(AVX512VBMI)
-DEFINE_BENCHMARK_PAIR(PREFETCHWT1)
-DEFINE_BENCHMARK_PAIR(SHA)
-DEFINE_BENCHMARK_PAIR(ADX)
-DEFINE_BENCHMARK_PAIR(RDRAND)
-DEFINE_BENCHMARK_PAIR(RDSEED)
-DEFINE_BENCHMARK_PAIR(PCOMMIT)
-DEFINE_BENCHMARK_PAIR(CLFLUSHOPT)
-DEFINE_BENCHMARK_PAIR(CLWB)
-
-#undef DEFINE_BENCHMARK_PAIR
+
+#include <util/system/cpu_id.h>
+
+#include <util/generic/xrange.h>
+
+#define DEFINE_BENCHMARK_PAIR(name) \
+ Y_CPU_BENCHMARK(Have##name, iface) { \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ Y_DO_NOT_OPTIMIZE_AWAY(NX86::Have##name()); \
+ } \
+ } \
+ \
+ Y_CPU_BENCHMARK(CachedHave##name, iface) { \
+ for (const auto i : xrange(iface.Iterations())) { \
+ Y_UNUSED(i); \
+ Y_DO_NOT_OPTIMIZE_AWAY(NX86::CachedHave##name()); \
+ } \
+ }
+
+DEFINE_BENCHMARK_PAIR(SSE)
+DEFINE_BENCHMARK_PAIR(SSE2)
+DEFINE_BENCHMARK_PAIR(SSE3)
+DEFINE_BENCHMARK_PAIR(SSSE3)
+DEFINE_BENCHMARK_PAIR(SSE41)
+DEFINE_BENCHMARK_PAIR(SSE42)
+DEFINE_BENCHMARK_PAIR(POPCNT)
+DEFINE_BENCHMARK_PAIR(BMI1)
+DEFINE_BENCHMARK_PAIR(AES)
+DEFINE_BENCHMARK_PAIR(AVX)
+DEFINE_BENCHMARK_PAIR(AVX2)
+DEFINE_BENCHMARK_PAIR(AVX512F)
+DEFINE_BENCHMARK_PAIR(AVX512DQ)
+DEFINE_BENCHMARK_PAIR(AVX512IFMA)
+DEFINE_BENCHMARK_PAIR(AVX512PF)
+DEFINE_BENCHMARK_PAIR(AVX512ER)
+DEFINE_BENCHMARK_PAIR(AVX512CD)
+DEFINE_BENCHMARK_PAIR(AVX512BW)
+DEFINE_BENCHMARK_PAIR(AVX512VL)
+DEFINE_BENCHMARK_PAIR(AVX512VBMI)
+DEFINE_BENCHMARK_PAIR(PREFETCHWT1)
+DEFINE_BENCHMARK_PAIR(SHA)
+DEFINE_BENCHMARK_PAIR(ADX)
+DEFINE_BENCHMARK_PAIR(RDRAND)
+DEFINE_BENCHMARK_PAIR(RDSEED)
+DEFINE_BENCHMARK_PAIR(PCOMMIT)
+DEFINE_BENCHMARK_PAIR(CLFLUSHOPT)
+DEFINE_BENCHMARK_PAIR(CLWB)
+
+#undef DEFINE_BENCHMARK_PAIR
diff --git a/util/system/benchmark/cpu_id/metrics/main.py b/util/system/benchmark/cpu_id/metrics/main.py
index 80ce8193b3..d9a86e825c 100644
--- a/util/system/benchmark/cpu_id/metrics/main.py
+++ b/util/system/benchmark/cpu_id/metrics/main.py
@@ -1,5 +1,5 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
metrics.set_benchmark(yc.execute_benchmark('util/system/benchmark/cpu_id/cpu_id', threads=8))
diff --git a/util/system/benchmark/cpu_id/metrics/ya.make b/util/system/benchmark/cpu_id/metrics/ya.make
index 46f950de28..8c55def99b 100644
--- a/util/system/benchmark/cpu_id/metrics/ya.make
+++ b/util/system/benchmark/cpu_id/metrics/ya.make
@@ -1,21 +1,21 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/system/benchmark/cpu_id)
-
-END()
+
+END()
diff --git a/util/system/benchmark/cpu_id/ya.make b/util/system/benchmark/cpu_id/ya.make
index a475d0c67f..976977014f 100644
--- a/util/system/benchmark/cpu_id/ya.make
+++ b/util/system/benchmark/cpu_id/ya.make
@@ -1,13 +1,13 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
Y_BENCHMARK()
-
-SRCS(
- main.cpp
-)
-
-END()
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/system/benchmark/create_destroy_thread/main.cpp b/util/system/benchmark/create_destroy_thread/main.cpp
index 8f9f5c9850..0ca2a9d96f 100644
--- a/util/system/benchmark/create_destroy_thread/main.cpp
+++ b/util/system/benchmark/create_destroy_thread/main.cpp
@@ -1,26 +1,26 @@
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/system/thread.h>
-
-static void* DoNothing(void*) noexcept {
- return nullptr;
-}
-
-Y_CPU_BENCHMARK(CreateDestroyThread, iface) {
- for (size_t i = 0, iEnd = iface.Iterations(); i < iEnd; ++i) {
- NBench::Clobber();
- TThread t(&DoNothing, nullptr);
- Y_DO_NOT_OPTIMIZE_AWAY(t);
- NBench::Clobber();
- }
-}
-
-Y_CPU_BENCHMARK(CreateRunDestroyThread, iface) {
- for (size_t i = 0, iEnd = iface.Iterations(); i < iEnd; ++i) {
- NBench::Clobber();
- TThread t(&DoNothing, nullptr);
- t.Start();
- NBench::Escape(t.Join());
- NBench::Clobber();
- }
-}
+
+#include <util/system/thread.h>
+
+static void* DoNothing(void*) noexcept {
+ return nullptr;
+}
+
+Y_CPU_BENCHMARK(CreateDestroyThread, iface) {
+ for (size_t i = 0, iEnd = iface.Iterations(); i < iEnd; ++i) {
+ NBench::Clobber();
+ TThread t(&DoNothing, nullptr);
+ Y_DO_NOT_OPTIMIZE_AWAY(t);
+ NBench::Clobber();
+ }
+}
+
+Y_CPU_BENCHMARK(CreateRunDestroyThread, iface) {
+ for (size_t i = 0, iEnd = iface.Iterations(); i < iEnd; ++i) {
+ NBench::Clobber();
+ TThread t(&DoNothing, nullptr);
+ t.Start();
+ NBench::Escape(t.Join());
+ NBench::Clobber();
+ }
+}
diff --git a/util/system/benchmark/create_destroy_thread/metrics/main.py b/util/system/benchmark/create_destroy_thread/metrics/main.py
index 3ee8f8a2ea..45564cda7f 100644
--- a/util/system/benchmark/create_destroy_thread/metrics/main.py
+++ b/util/system/benchmark/create_destroy_thread/metrics/main.py
@@ -1,7 +1,7 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
metrics.set_benchmark(
yc.execute_benchmark('util/system/benchmark/create_destroy_thread/create_destroy_thread', threads=8)
)
diff --git a/util/system/benchmark/create_destroy_thread/metrics/ya.make b/util/system/benchmark/create_destroy_thread/metrics/ya.make
index 9498e47812..d526487e1a 100644
--- a/util/system/benchmark/create_destroy_thread/metrics/ya.make
+++ b/util/system/benchmark/create_destroy_thread/metrics/ya.make
@@ -1,21 +1,21 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/system/benchmark/create_destroy_thread)
-
-END()
+
+END()
diff --git a/util/system/benchmark/create_destroy_thread/ya.make b/util/system/benchmark/create_destroy_thread/ya.make
index c50840aaad..03eb0ec8e0 100644
--- a/util/system/benchmark/create_destroy_thread/ya.make
+++ b/util/system/benchmark/create_destroy_thread/ya.make
@@ -1,9 +1,9 @@
OWNER(yazevnul)
-
+
Y_BENCHMARK()
-
-SRCS(
- main.cpp
-)
-
-END()
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/system/benchmark/ya.make b/util/system/benchmark/ya.make
index 262bc5b090..12fa9af9d6 100644
--- a/util/system/benchmark/ya.make
+++ b/util/system/benchmark/ya.make
@@ -1,15 +1,15 @@
-OWNER(
- yazevnul
+OWNER(
+ yazevnul
g:util
-)
+)
SUBSCRIBER(g:util-subscribers)
-
-RECURSE(
- cpu_id
- cpu_id/metrics
- create_destroy_thread
- create_destroy_thread/metrics
-)
+
+RECURSE(
+ cpu_id
+ cpu_id/metrics
+ create_destroy_thread
+ create_destroy_thread/metrics
+)
IF (NOT OS_WINDOWS)
RECURSE(
diff --git a/util/system/compat_ut.cpp b/util/system/compat_ut.cpp
index ead2e58865..dbd9289c17 100644
--- a/util/system/compat_ut.cpp
+++ b/util/system/compat_ut.cpp
@@ -5,8 +5,8 @@
#include <util/folder/dirut.h>
#include <util/stream/output.h>
-Y_UNIT_TEST_SUITE(TCompatTest) {
- Y_UNIT_TEST(TestGetprogname) {
+Y_UNIT_TEST_SUITE(TCompatTest) {
+ Y_UNIT_TEST(TestGetprogname) {
getprogname(); // just check it links
}
}
diff --git a/util/system/compiler.h b/util/system/compiler.h
index 8b8373f584..b373edcc46 100644
--- a/util/system/compiler.h
+++ b/util/system/compiler.h
@@ -6,36 +6,36 @@
// useful cross-platfrom definitions for compilers
-/**
- * @def Y_FUNC_SIGNATURE
- *
- * Use this macro to get pretty function name (see example).
- *
- * @code
- * void Hi() {
- * Cout << Y_FUNC_SIGNATURE << Endl;
- * }
-
- * template <typename T>
- * void Do() {
- * Cout << Y_FUNC_SIGNATURE << Endl;
- * }
-
- * int main() {
- * Hi(); // void Hi()
- * Do<int>(); // void Do() [T = int]
+/**
+ * @def Y_FUNC_SIGNATURE
+ *
+ * Use this macro to get pretty function name (see example).
+ *
+ * @code
+ * void Hi() {
+ * Cout << Y_FUNC_SIGNATURE << Endl;
+ * }
+
+ * template <typename T>
+ * void Do() {
+ * Cout << Y_FUNC_SIGNATURE << Endl;
+ * }
+
+ * int main() {
+ * Hi(); // void Hi()
+ * Do<int>(); // void Do() [T = int]
* Do<TString>(); // void Do() [T = TString]
- * }
- * @endcode
- */
-#if defined(__GNUC__)
+ * }
+ * @endcode
+ */
+#if defined(__GNUC__)
#define Y_FUNC_SIGNATURE __PRETTY_FUNCTION__
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER)
#define Y_FUNC_SIGNATURE __FUNCSIG__
-#else
+#else
#define Y_FUNC_SIGNATURE ""
-#endif
-
+#endif
+
#ifdef __GNUC__
#define Y_PRINTF_FORMAT(n, m) __attribute__((__format__(__printf__, n, m)))
#endif
@@ -53,26 +53,26 @@
#endif
/**
- * @def Y_DECLARE_UNUSED
- *
- * Macro is needed to silence compiler warning about unused entities (e.g. function or argument).
- *
- * @code
- * Y_DECLARE_UNUSED int FunctionUsedSolelyForDebugPurposes();
- * assert(FunctionUsedSolelyForDebugPurposes() == 42);
- *
- * void Foo(const int argumentUsedOnlyForDebugPurposes Y_DECLARE_UNUSED) {
- * assert(argumentUsedOnlyForDebugPurposes == 42);
- * // however you may as well omit `Y_DECLARE_UNUSED` and use `UNUSED` macro instead
- * Y_UNUSED(argumentUsedOnlyForDebugPurposes);
- * }
- * @endcode
- */
+ * @def Y_DECLARE_UNUSED
+ *
+ * Macro is needed to silence compiler warning about unused entities (e.g. function or argument).
+ *
+ * @code
+ * Y_DECLARE_UNUSED int FunctionUsedSolelyForDebugPurposes();
+ * assert(FunctionUsedSolelyForDebugPurposes() == 42);
+ *
+ * void Foo(const int argumentUsedOnlyForDebugPurposes Y_DECLARE_UNUSED) {
+ * assert(argumentUsedOnlyForDebugPurposes == 42);
+ * // however you may as well omit `Y_DECLARE_UNUSED` and use `UNUSED` macro instead
+ * Y_UNUSED(argumentUsedOnlyForDebugPurposes);
+ * }
+ * @endcode
+ */
#ifdef __GNUC__
#define Y_DECLARE_UNUSED __attribute__((unused))
#endif
-#ifndef Y_DECLARE_UNUSED
+#ifndef Y_DECLARE_UNUSED
#define Y_DECLARE_UNUSED
#endif
@@ -152,7 +152,7 @@
#define Y_PREFETCH_WRITE(Pointer, Priority) (void)(const void*)(Pointer), (void)Priority
#endif
-#ifndef Y_LIKELY
+#ifndef Y_LIKELY
#define Y_LIKELY(Cond) (Cond)
#define Y_UNLIKELY(Cond) (Cond)
#endif
diff --git a/util/system/compiler_ut.cpp b/util/system/compiler_ut.cpp
index aaeb935b16..f93b1c0850 100644
--- a/util/system/compiler_ut.cpp
+++ b/util/system/compiler_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TCompilerTest) {
- Y_UNIT_TEST(TestPragmaNoWshadow) {
+Y_UNIT_TEST_SUITE(TCompilerTest) {
+ Y_UNIT_TEST(TestPragmaNoWshadow) {
Y_PRAGMA_DIAGNOSTIC_PUSH
Y_PRAGMA_NO_WSHADOW
@@ -34,7 +34,7 @@ Y_UNIT_TEST_SUITE(TCompilerTest) {
UNIT_ASSERT_EQUAL(Foo(1), 0);
}
- Y_UNIT_TEST(TestHaveInt128) {
+ Y_UNIT_TEST(TestHaveInt128) {
#ifdef Y_HAVE_INT128
// will be compiled without errors
unsigned __int128 a = 1;
diff --git a/util/system/condvar.cpp b/util/system/condvar.cpp
index 2eeb720f9f..62f3d22356 100644
--- a/util/system/condvar.cpp
+++ b/util/system/condvar.cpp
@@ -28,7 +28,7 @@ namespace {
public:
inline ~TCondVarImpl() {
- Y_ASSERT(Events_.Empty());
+ Y_ASSERT(Events_.Empty());
}
inline void Signal() noexcept {
@@ -81,25 +81,25 @@ class TCondVar::TImpl: public TCondVarImpl {
class TCondVar::TImpl {
public:
inline TImpl() {
- if (pthread_cond_init(&Cond_, nullptr)) {
+ if (pthread_cond_init(&Cond_, nullptr)) {
ythrow yexception() << "can not create condvar(" << LastSystemErrorText() << ")";
}
}
inline ~TImpl() {
int ret = pthread_cond_destroy(&Cond_);
- Y_VERIFY(ret == 0, "pthread_cond_destroy failed: %s", LastSystemErrorText(ret));
+ Y_VERIFY(ret == 0, "pthread_cond_destroy failed: %s", LastSystemErrorText(ret));
}
inline void Signal() noexcept {
int ret = pthread_cond_signal(&Cond_);
- Y_VERIFY(ret == 0, "pthread_cond_signal failed: %s", LastSystemErrorText(ret));
+ Y_VERIFY(ret == 0, "pthread_cond_signal failed: %s", LastSystemErrorText(ret));
}
inline bool WaitD(TMutex& lock, TInstant deadLine) noexcept {
if (deadLine == TInstant::Max()) {
int ret = pthread_cond_wait(&Cond_, (pthread_mutex_t*)lock.Handle());
- Y_VERIFY(ret == 0, "pthread_cond_wait failed: %s", LastSystemErrorText(ret));
+ Y_VERIFY(ret == 0, "pthread_cond_wait failed: %s", LastSystemErrorText(ret));
return true;
} else {
struct timespec spec;
@@ -111,7 +111,7 @@ public:
int ret = pthread_cond_timedwait(&Cond_, (pthread_mutex_t*)lock.Handle(), &spec);
- Y_VERIFY(ret == 0 || ret == ETIMEDOUT, "pthread_cond_timedwait failed: %s", LastSystemErrorText(ret));
+ Y_VERIFY(ret == 0 || ret == ETIMEDOUT, "pthread_cond_timedwait failed: %s", LastSystemErrorText(ret));
return ret == 0;
}
@@ -119,7 +119,7 @@ public:
inline void BroadCast() noexcept {
int ret = pthread_cond_broadcast(&Cond_);
- Y_VERIFY(ret == 0, "pthread_cond_broadcast failed: %s", LastSystemErrorText(ret));
+ Y_VERIFY(ret == 0, "pthread_cond_broadcast failed: %s", LastSystemErrorText(ret));
}
private:
diff --git a/util/system/condvar.h b/util/system/condvar.h
index 911ace52c6..569162717c 100644
--- a/util/system/condvar.h
+++ b/util/system/condvar.h
@@ -6,8 +6,8 @@
#include <util/generic/noncopyable.h>
#include <util/datetime/base.h>
-#include <utility>
-
+#include <utility>
+
class TCondVar {
public:
TCondVar();
@@ -19,30 +19,30 @@ public:
/*
* returns false if failed by timeout
*/
- bool WaitD(TMutex& m, TInstant deadline) noexcept;
+ bool WaitD(TMutex& m, TInstant deadline) noexcept;
+
+ template <typename P>
+ inline bool WaitD(TMutex& m, TInstant deadline, P pred) noexcept {
+ while (!pred()) {
+ if (!WaitD(m, deadline)) {
+ return pred();
+ }
+ }
+ return true;
+ }
- template <typename P>
- inline bool WaitD(TMutex& m, TInstant deadline, P pred) noexcept {
- while (!pred()) {
- if (!WaitD(m, deadline)) {
- return pred();
- }
- }
- return true;
- }
-
/*
* returns false if failed by timeout
*/
- inline bool WaitT(TMutex& m, TDuration timeout) noexcept {
- return WaitD(m, timeout.ToDeadLine());
+ inline bool WaitT(TMutex& m, TDuration timeout) noexcept {
+ return WaitD(m, timeout.ToDeadLine());
+ }
+
+ template <typename P>
+ inline bool WaitT(TMutex& m, TDuration timeout, P pred) noexcept {
+ return WaitD(m, timeout.ToDeadLine(), std::move(pred));
}
- template <typename P>
- inline bool WaitT(TMutex& m, TDuration timeout, P pred) noexcept {
- return WaitD(m, timeout.ToDeadLine(), std::move(pred));
- }
-
/*
* infinite wait
*/
@@ -50,21 +50,21 @@ public:
WaitD(m, TInstant::Max());
}
- template <typename P>
- inline void WaitI(TMutex& m, P pred) noexcept {
- WaitD(m, TInstant::Max(), std::move(pred));
- }
-
+ template <typename P>
+ inline void WaitI(TMutex& m, P pred) noexcept {
+ WaitD(m, TInstant::Max(), std::move(pred));
+ }
+
//deprecated
inline void Wait(TMutex& m) noexcept {
WaitI(m);
}
- template <typename P>
- inline void Wait(TMutex& m, P pred) noexcept {
- WaitI(m, std::move(pred));
- }
-
+ template <typename P>
+ inline void Wait(TMutex& m, P pred) noexcept {
+ WaitI(m, std::move(pred));
+ }
+
private:
class TImpl;
THolder<TImpl> Impl_;
diff --git a/util/system/condvar_ut.cpp b/util/system/condvar_ut.cpp
index 696516c810..5130a18d32 100644
--- a/util/system/condvar_ut.cpp
+++ b/util/system/condvar_ut.cpp
@@ -4,8 +4,8 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/system/atomic.h>
-#include <util/system/atomic_ops.h>
+#include <util/system/atomic.h>
+#include <util/system/atomic_ops.h>
#include <util/thread/pool.h>
class TCondVarTest: public TTestBase {
@@ -28,12 +28,12 @@ class TCondVarTest: public TTestBase {
TCondVar condVar1;
TCondVar condVar2;
- TAtomic stopWaiting;
+ TAtomic stopWaiting;
- TAtomic in;
- TAtomic out;
+ TAtomic in;
+ TAtomic out;
- TAtomic waited;
+ TAtomic waited;
bool failed;
};
@@ -61,17 +61,36 @@ class TCondVarTest: public TTestBase {
Data_.failed = true; \
}
void RunBasics() {
- Y_ASSERT(TotalIds_ == 3);
+ Y_ASSERT(TotalIds_ == 3);
if (Id_ < 2) {
TGuard<TMutex> guard(Data_.mutex);
- while (!AtomicGet(Data_.stopWaiting)) {
+ while (!AtomicGet(Data_.stopWaiting)) {
bool res = Data_.condVar1.WaitT(Data_.mutex, TDuration::Seconds(1));
FAIL_ASSERT(res == true);
}
} else {
usleep(100000);
- AtomicSet(Data_.stopWaiting, true);
+ AtomicSet(Data_.stopWaiting, true);
+
+ TGuard<TMutex> guard(Data_.mutex);
+ Data_.condVar1.Signal();
+ Data_.condVar1.Signal();
+ }
+ }
+
+ void RunBasicsWithPredicate() {
+ Y_ASSERT(TotalIds_ == 3);
+
+ if (Id_ < 2) {
+ TGuard<TMutex> guard(Data_.mutex);
+ const auto res = Data_.condVar1.WaitT(Data_.mutex, TDuration::Seconds(1), [&] {
+ return AtomicGet(Data_.stopWaiting);
+ });
+ FAIL_ASSERT(res == true);
+ } else {
+ usleep(100000);
+ AtomicSet(Data_.stopWaiting, true);
TGuard<TMutex> guard(Data_.mutex);
Data_.condVar1.Signal();
@@ -79,82 +98,63 @@ class TCondVarTest: public TTestBase {
}
}
- void RunBasicsWithPredicate() {
- Y_ASSERT(TotalIds_ == 3);
-
- if (Id_ < 2) {
- TGuard<TMutex> guard(Data_.mutex);
- const auto res = Data_.condVar1.WaitT(Data_.mutex, TDuration::Seconds(1), [&] {
- return AtomicGet(Data_.stopWaiting);
- });
- FAIL_ASSERT(res == true);
- } else {
- usleep(100000);
- AtomicSet(Data_.stopWaiting, true);
-
- TGuard<TMutex> guard(Data_.mutex);
- Data_.condVar1.Signal();
- Data_.condVar1.Signal();
- }
- }
-
void RunSyncronize() {
for (size_t i = 0; i < 10; ++i) {
TGuard<TMutex> guard(Data_.mutex);
- AtomicIncrement(Data_.in);
- if (AtomicGet(Data_.in) == TotalIds_) {
- AtomicSet(Data_.out, 0);
+ AtomicIncrement(Data_.in);
+ if (AtomicGet(Data_.in) == TotalIds_) {
+ AtomicSet(Data_.out, 0);
Data_.condVar1.BroadCast();
} else {
- AtomicIncrement(Data_.waited);
- while (AtomicGet(Data_.in) < TotalIds_) {
+ AtomicIncrement(Data_.waited);
+ while (AtomicGet(Data_.in) < TotalIds_) {
bool res = Data_.condVar1.WaitT(Data_.mutex, TDuration::Seconds(1));
FAIL_ASSERT(res == true);
}
}
- AtomicIncrement(Data_.out);
- if (AtomicGet(Data_.out) == TotalIds_) {
- AtomicSet(Data_.in, 0);
+ AtomicIncrement(Data_.out);
+ if (AtomicGet(Data_.out) == TotalIds_) {
+ AtomicSet(Data_.in, 0);
Data_.condVar2.BroadCast();
} else {
- while (AtomicGet(Data_.out) < TotalIds_) {
+ while (AtomicGet(Data_.out) < TotalIds_) {
bool res = Data_.condVar2.WaitT(Data_.mutex, TDuration::Seconds(1));
FAIL_ASSERT(res == true);
}
}
}
- FAIL_ASSERT(AtomicGet(Data_.waited) == (TotalIds_ - 1) * 10);
- }
-
- void RunSyncronizeWithPredicate() {
- for (size_t i = 0; i < 10; ++i) {
- TGuard<TMutex> guard(Data_.mutex);
- AtomicIncrement(Data_.in);
- if (AtomicGet(Data_.in) == TotalIds_) {
- AtomicSet(Data_.out, 0);
- Data_.condVar1.BroadCast();
- } else {
- AtomicIncrement(Data_.waited);
- const auto res = Data_.condVar1.WaitT(Data_.mutex, TDuration::Seconds(1), [&] {
- return AtomicGet(Data_.in) >= TotalIds_;
- });
- FAIL_ASSERT(res == true);
- }
-
- AtomicIncrement(Data_.out);
- if (AtomicGet(Data_.out) == TotalIds_) {
- AtomicSet(Data_.in, 0);
- Data_.condVar2.BroadCast();
- } else {
- const auto res = Data_.condVar2.WaitT(Data_.mutex, TDuration::Seconds(1), [&] {
- return AtomicGet(Data_.out) >= TotalIds_;
- });
- FAIL_ASSERT(res == true);
- }
- }
-
+ FAIL_ASSERT(AtomicGet(Data_.waited) == (TotalIds_ - 1) * 10);
+ }
+
+ void RunSyncronizeWithPredicate() {
+ for (size_t i = 0; i < 10; ++i) {
+ TGuard<TMutex> guard(Data_.mutex);
+ AtomicIncrement(Data_.in);
+ if (AtomicGet(Data_.in) == TotalIds_) {
+ AtomicSet(Data_.out, 0);
+ Data_.condVar1.BroadCast();
+ } else {
+ AtomicIncrement(Data_.waited);
+ const auto res = Data_.condVar1.WaitT(Data_.mutex, TDuration::Seconds(1), [&] {
+ return AtomicGet(Data_.in) >= TotalIds_;
+ });
+ FAIL_ASSERT(res == true);
+ }
+
+ AtomicIncrement(Data_.out);
+ if (AtomicGet(Data_.out) == TotalIds_) {
+ AtomicSet(Data_.in, 0);
+ Data_.condVar2.BroadCast();
+ } else {
+ const auto res = Data_.condVar2.WaitT(Data_.mutex, TDuration::Seconds(1), [&] {
+ return AtomicGet(Data_.out) >= TotalIds_;
+ });
+ FAIL_ASSERT(res == true);
+ }
+ }
+
FAIL_ASSERT(Data_.waited == (TotalIds_ - 1) * 10);
}
#undef FAIL_ASSERT
@@ -162,7 +162,7 @@ class TCondVarTest: public TTestBase {
private:
PFunc Func_;
size_t Id_;
- TAtomicBase TotalIds_;
+ TAtomicBase TotalIds_;
TSharedData& Data_;
};
@@ -181,17 +181,17 @@ private:
RUN_CYCLE(RunBasics, 3);
}
- inline void TestBasicsWithPredicate() {
- RUN_CYCLE(RunBasicsWithPredicate, 3);
- }
-
+ inline void TestBasicsWithPredicate() {
+ RUN_CYCLE(RunBasicsWithPredicate, 3);
+ }
+
inline void TestSyncronize() {
RUN_CYCLE(RunSyncronize, 6);
}
-
- inline void TestSyncronizeWithPredicate() {
- RUN_CYCLE(RunSyncronizeWithPredicate, 6);
- }
+
+ inline void TestSyncronizeWithPredicate() {
+ RUN_CYCLE(RunSyncronizeWithPredicate, 6);
+ }
#undef RUN_CYCLE
TSharedData Data_;
TThreadPool Q_;
diff --git a/util/system/context.cpp b/util/system/context.cpp
index d108105da0..ad99309088 100644
--- a/util/system/context.cpp
+++ b/util/system/context.cpp
@@ -127,7 +127,7 @@ namespace {
Y_NO_SANITIZE("address")
Y_NO_SANITIZE("memory") static void ContextTrampoLine() {
void** argPtr = (void**)((char*)AlignUp(&argPtr + EXTRA_PUSH_ARGS, STACK_ALIGN) + STACK_ALIGN);
- Y_ASSERT(*(argPtr - 1) == *(argPtr - 2));
+ Y_ASSERT(*(argPtr - 1) == *(argPtr - 2));
Run(*(argPtr - 1));
}
@@ -183,7 +183,7 @@ TContMachineContext::TContMachineContext(const TContClosure& c)
* fake return address
*/
for (size_t i = 0; i < EXTRA_PUSH_ARGS; ++i) {
- stack.Push(nullptr);
+ stack.Push(nullptr);
}
#endif
@@ -249,7 +249,7 @@ void TContMachineContext::SwitchTo(TContMachineContext* next) noexcept {
struct TContMachineContext::TImpl {
inline TImpl()
- : TL(nullptr)
+ : TL(nullptr)
, Finish(false)
{
}
diff --git a/util/system/context_ut.cpp b/util/system/context_ut.cpp
index 9fac04fc08..45cb0249f7 100644
--- a/util/system/context_ut.cpp
+++ b/util/system/context_ut.cpp
@@ -5,7 +5,7 @@
#include <util/generic/deque.h>
#include <util/generic/yexception.h>
-Y_UNIT_TEST_SUITE(TestContext) {
+Y_UNIT_TEST_SUITE(TestContext) {
template <class F>
static TContClosure Wrap(F& f) {
struct TW: public ITrampoLine {
@@ -29,7 +29,7 @@ Y_UNIT_TEST_SUITE(TestContext) {
return {&tw, TArrayRef(tw.Buf, sizeof(tw.Buf))};
}
- Y_UNIT_TEST(TestExceptionSafety) {
+ Y_UNIT_TEST(TestExceptionSafety) {
TExceptionSafeContext main;
TExceptionSafeContext* volatile nextPtr = nullptr;
diff --git a/util/system/cpu_id.cpp b/util/system/cpu_id.cpp
index 37f923932a..598c71f4d9 100644
--- a/util/system/cpu_id.cpp
+++ b/util/system/cpu_id.cpp
@@ -4,53 +4,53 @@
#include <util/generic/singleton.h>
-#if defined(_win_)
+#if defined(_win_)
#include <intrin.h>
#include <immintrin.h>
-#elif defined(_x86_)
+#elif defined(_x86_)
#include <cpuid.h>
#endif
#include <string.h>
-#if defined(_x86_) && !defined(_win_)
-static ui64 _xgetbv(ui32 xcr) {
- ui32 eax;
- ui32 edx;
+#if defined(_x86_) && !defined(_win_)
+static ui64 _xgetbv(ui32 xcr) {
+ ui32 eax;
+ ui32 edx;
__asm__ volatile(
"xgetbv"
: "=a"(eax), "=d"(edx)
: "c"(xcr));
- return (static_cast<ui64>(edx) << 32) | eax;
-}
-#endif
-
-bool NX86::CpuId(ui32 op, ui32 subOp, ui32* res) noexcept {
-#if defined(_x86_)
+ return (static_cast<ui64>(edx) << 32) | eax;
+}
+#endif
+
+bool NX86::CpuId(ui32 op, ui32 subOp, ui32* res) noexcept {
+#if defined(_x86_)
#if defined(_MSC_VER)
- static_assert(sizeof(int) == sizeof(ui32), "ups, something wrong here");
- __cpuidex((int*)res, op, subOp);
+ static_assert(sizeof(int) == sizeof(ui32), "ups, something wrong here");
+ __cpuidex((int*)res, op, subOp);
#else
- __cpuid_count(op, subOp, res[0], res[1], res[2], res[3]);
+ __cpuid_count(op, subOp, res[0], res[1], res[2], res[3]);
#endif
- return true;
-#else
- (void)op;
- (void)subOp;
-
- memset(res, 0, 4 * sizeof(ui32));
-
- return false;
-#endif
-}
-
-bool NX86::CpuId(ui32 op, ui32* res) noexcept {
+ return true;
+#else
+ (void)op;
+ (void)subOp;
+
+ memset(res, 0, 4 * sizeof(ui32));
+
+ return false;
+#endif
+}
+
+bool NX86::CpuId(ui32 op, ui32* res) noexcept {
#if defined(_x86_)
#if defined(_MSC_VER)
static_assert(sizeof(int) == sizeof(ui32), "ups, something wrong here");
__cpuid((int*)res, op);
#else
- __cpuid(op, res[0], res[1], res[2], res[3]);
+ __cpuid(op, res[0], res[1], res[2], res[3]);
#endif
return true;
#else
@@ -73,13 +73,13 @@ namespace {
ui32 EDX;
};
- inline TX86CpuInfo(ui32 op) noexcept {
+ inline TX86CpuInfo(ui32 op) noexcept {
NX86::CpuId(op, Info);
}
-
- inline TX86CpuInfo(ui32 op, ui32 subOp) noexcept {
- NX86::CpuId(op, subOp, Info);
- }
+
+ inline TX86CpuInfo(ui32 op, ui32 subOp) noexcept {
+ NX86::CpuId(op, subOp, Info);
+ }
};
static_assert(sizeof(TX86CpuInfo) == 16, "please, fix me");
@@ -90,15 +90,15 @@ bool NX86::HaveRDTSCP() noexcept {
return (TX86CpuInfo(0x80000001).EDX >> 27) & 1u;
}
-bool NX86::HaveSSE() noexcept {
+bool NX86::HaveSSE() noexcept {
return (TX86CpuInfo(0x1).EDX >> 25) & 1u;
}
-bool NX86::HaveSSE2() noexcept {
+bool NX86::HaveSSE2() noexcept {
return (TX86CpuInfo(0x1).EDX >> 26) & 1u;
}
-bool NX86::HaveSSE3() noexcept {
+bool NX86::HaveSSE3() noexcept {
return TX86CpuInfo(0x1).ECX & 1u;
}
@@ -106,15 +106,15 @@ bool NX86::HavePCLMUL() noexcept {
return (TX86CpuInfo(0x1).ECX >> 1) & 1u;
}
-bool NX86::HaveSSSE3() noexcept {
+bool NX86::HaveSSSE3() noexcept {
return (TX86CpuInfo(0x1).ECX >> 9) & 1u;
}
-bool NX86::HaveSSE41() noexcept {
+bool NX86::HaveSSE41() noexcept {
return (TX86CpuInfo(0x1).ECX >> 19) & 1u;
}
-bool NX86::HaveSSE42() noexcept {
+bool NX86::HaveSSE42() noexcept {
return (TX86CpuInfo(0x1).ECX >> 20) & 1u;
}
@@ -122,51 +122,51 @@ bool NX86::HaveF16C() noexcept {
return (TX86CpuInfo(0x1).ECX >> 29) & 1u;
}
-bool NX86::HavePOPCNT() noexcept {
+bool NX86::HavePOPCNT() noexcept {
return (TX86CpuInfo(0x1).ECX >> 23) & 1u;
}
-bool NX86::HaveAES() noexcept {
+bool NX86::HaveAES() noexcept {
return (TX86CpuInfo(0x1).ECX >> 25) & 1u;
}
-bool NX86::HaveXSAVE() noexcept {
- return (TX86CpuInfo(0x1).ECX >> 26) & 1u;
-}
-
-bool NX86::HaveOSXSAVE() noexcept {
- return (TX86CpuInfo(0x1).ECX >> 27) & 1u;
-}
-
-bool NX86::HaveAVX() noexcept {
+bool NX86::HaveXSAVE() noexcept {
+ return (TX86CpuInfo(0x1).ECX >> 26) & 1u;
+}
+
+bool NX86::HaveOSXSAVE() noexcept {
+ return (TX86CpuInfo(0x1).ECX >> 27) & 1u;
+}
+
+bool NX86::HaveAVX() noexcept {
#if defined(_x86_)
// http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf
- // https://bugs.chromium.org/p/chromium/issues/detail?id=375968
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=375968
return HaveOSXSAVE() // implies HaveXSAVE()
&& (_xgetbv(0) & 6u) == 6u // XMM state and YMM state are enabled by OS
&& ((TX86CpuInfo(0x1).ECX >> 28) & 1u); // AVX bit
-#else
+#else
return false;
-#endif
+#endif
}
-bool NX86::HaveFMA() noexcept {
+bool NX86::HaveFMA() noexcept {
return HaveAVX() && ((TX86CpuInfo(0x1).ECX >> 12) & 1u);
}
-bool NX86::HaveAVX2() noexcept {
+bool NX86::HaveAVX2() noexcept {
return HaveAVX() && ((TX86CpuInfo(0x7, 0).EBX >> 5) & 1u);
-}
-
-bool NX86::HaveBMI1() noexcept {
- return (TX86CpuInfo(0x7, 0).EBX >> 3) & 1u;
-}
-
+}
+
+bool NX86::HaveBMI1() noexcept {
+ return (TX86CpuInfo(0x7, 0).EBX >> 3) & 1u;
+}
+
bool NX86::HaveBMI2() noexcept {
return (TX86CpuInfo(0x7, 0).EBX >> 8) & 1u;
}
-bool NX86::HaveAVX512F() noexcept {
+bool NX86::HaveAVX512F() noexcept {
#if defined(_x86_)
// https://software.intel.com/en-us/articles/how-to-detect-knl-instruction-support
return HaveOSXSAVE() // implies HaveXSAVE()
@@ -177,73 +177,73 @@ bool NX86::HaveAVX512F() noexcept {
#else
return false;
#endif
-}
-
-bool NX86::HaveAVX512DQ() noexcept {
+}
+
+bool NX86::HaveAVX512DQ() noexcept {
return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 17) & 1u);
-}
-
-bool NX86::HaveRDSEED() noexcept {
+}
+
+bool NX86::HaveRDSEED() noexcept {
return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 18) & 1u);
-}
-
-bool NX86::HaveADX() noexcept {
+}
+
+bool NX86::HaveADX() noexcept {
return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 19) & 1u);
-}
-
-bool NX86::HaveAVX512IFMA() noexcept {
+}
+
+bool NX86::HaveAVX512IFMA() noexcept {
return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 21) & 1u);
-}
-
-bool NX86::HavePCOMMIT() noexcept {
+}
+
+bool NX86::HavePCOMMIT() noexcept {
return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 22) & 1u);
-}
-
-bool NX86::HaveCLFLUSHOPT() noexcept {
+}
+
+bool NX86::HaveCLFLUSHOPT() noexcept {
return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 23) & 1u);
-}
-
-bool NX86::HaveCLWB() noexcept {
+}
+
+bool NX86::HaveCLWB() noexcept {
return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 24) & 1u);
-}
-
-bool NX86::HaveAVX512PF() noexcept {
+}
+
+bool NX86::HaveAVX512PF() noexcept {
return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 26) & 1u);
-}
-
-bool NX86::HaveAVX512ER() noexcept {
+}
+
+bool NX86::HaveAVX512ER() noexcept {
return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 27) & 1u);
-}
-
-bool NX86::HaveAVX512CD() noexcept {
+}
+
+bool NX86::HaveAVX512CD() noexcept {
return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 28) & 1u);
-}
-
-bool NX86::HaveSHA() noexcept {
+}
+
+bool NX86::HaveSHA() noexcept {
return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 29) & 1u);
-}
-
-bool NX86::HaveAVX512BW() noexcept {
+}
+
+bool NX86::HaveAVX512BW() noexcept {
return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 30) & 1u);
-}
-
-bool NX86::HaveAVX512VL() noexcept {
+}
+
+bool NX86::HaveAVX512VL() noexcept {
return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 31) & 1u);
-}
-
-bool NX86::HavePREFETCHWT1() noexcept {
+}
+
+bool NX86::HavePREFETCHWT1() noexcept {
return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).ECX >> 0) & 1u);
-}
-
-bool NX86::HaveAVX512VBMI() noexcept {
+}
+
+bool NX86::HaveAVX512VBMI() noexcept {
return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).ECX >> 1) & 1u);
-}
-
-bool NX86::HaveRDRAND() noexcept {
+}
+
+bool NX86::HaveRDRAND() noexcept {
return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x1).ECX >> 30) & 1u);
}
-const char* CpuBrand(ui32* store) noexcept {
+const char* CpuBrand(ui32* store) noexcept {
memset(store, 0, 12 * sizeof(*store));
#if defined(_x86_)
diff --git a/util/system/cpu_id.h b/util/system/cpu_id.h
index 5f30c415c1..3c49e728a7 100644
--- a/util/system/cpu_id.h
+++ b/util/system/cpu_id.h
@@ -75,13 +75,13 @@ namespace NX86 {
/**
* returns false on non-x86 platforms
*/
- bool CpuId(ui32 op, ui32 res[4]) noexcept;
- bool CpuId(ui32 op, ui32 subOp, ui32 res[4]) noexcept;
-
+ bool CpuId(ui32 op, ui32 res[4]) noexcept;
+ bool CpuId(ui32 op, ui32 subOp, ui32 res[4]) noexcept;
+
#define Y_DEF_NAME(X) Y_CONST_FUNCTION bool Have##X() noexcept;
Y_CPU_ID_ENUMERATE(Y_DEF_NAME)
#undef Y_DEF_NAME
-
+
#define Y_DEF_NAME(X) Y_CONST_FUNCTION bool CachedHave##X() noexcept;
Y_CPU_ID_ENUMERATE_OUTLINED_CACHED_DEFINE(Y_DEF_NAME)
#undef Y_DEF_NAME
@@ -154,4 +154,4 @@ namespace NX86 {
}
-const char* CpuBrand(ui32 store[12]) noexcept;
+const char* CpuBrand(ui32 store[12]) noexcept;
diff --git a/util/system/cpu_id_ut.cpp b/util/system/cpu_id_ut.cpp
index 1164196479..68f1f8aac7 100644
--- a/util/system/cpu_id_ut.cpp
+++ b/util/system/cpu_id_ut.cpp
@@ -1,51 +1,51 @@
#include "cpu_id.h"
-#include "platform.h"
-
+#include "platform.h"
+
#include <library/cpp/testing/unittest/registar.h>
-// There are no tests yet for instructions that use 512-bit wide registers because they are not
-// supported by some compilers yet.
-// Relevant review in LLVM https://reviews.llvm.org/D16757, we should wait untill it will be in our
-// version of Clang.
-//
-// There are also no tests for PREFETCHWT1, PCOMMIT, CLFLUSHOPT and CLWB as they are not supported
-// by our compilers yet (and there are no available processors yet :).
-
-static void ExecuteSSEInstruction();
-static void ExecuteSSE2Instruction();
-static void ExecuteSSE3Instruction();
-static void ExecuteSSSE3Instruction();
-static void ExecuteSSE41Instruction();
-static void ExecuteSSE42Instruction();
+// There are no tests yet for instructions that use 512-bit wide registers because they are not
+// supported by some compilers yet.
+// Relevant review in LLVM https://reviews.llvm.org/D16757, we should wait untill it will be in our
+// version of Clang.
+//
+// There are also no tests for PREFETCHWT1, PCOMMIT, CLFLUSHOPT and CLWB as they are not supported
+// by our compilers yet (and there are no available processors yet :).
+
+static void ExecuteSSEInstruction();
+static void ExecuteSSE2Instruction();
+static void ExecuteSSE3Instruction();
+static void ExecuteSSSE3Instruction();
+static void ExecuteSSE41Instruction();
+static void ExecuteSSE42Instruction();
static void ExecuteF16CInstruction();
-static void ExecuteAVXInstruction();
-static void ExecuteAVX2Instruction();
-static void ExecutePOPCNTInstruction();
-static void ExecuteBMI1Instruction();
+static void ExecuteAVXInstruction();
+static void ExecuteAVX2Instruction();
+static void ExecutePOPCNTInstruction();
+static void ExecuteBMI1Instruction();
static void ExecuteBMI2Instruction();
static void ExecutePCLMULInstruction();
-static void ExecuteAESInstruction();
-static void ExecuteAVXInstruction();
-static void ExecuteAVX2Instruction();
-static void ExecuteAVX512FInstruction();
-static void ExecuteAVX512DQInstruction();
-static void ExecuteAVX512IFMAInstruction();
-static void ExecuteAVX512PFInstruction();
-static void ExecuteAVX512ERInstruction();
-static void ExecuteAVX512CDInstruction();
-static void ExecuteAVX512BWInstruction();
-static void ExecuteAVX512VLInstruction();
-static void ExecuteAVX512VBMIInstruction();
-static void ExecutePREFETCHWT1Instruction();
-static void ExecuteSHAInstruction();
-static void ExecuteADXInstruction();
-static void ExecuteRDRANDInstruction();
-static void ExecuteRDSEEDInstruction();
-static void ExecutePCOMMITInstruction();
-static void ExecuteCLFLUSHOPTInstruction();
-static void ExecuteCLWBInstruction();
-
+static void ExecuteAESInstruction();
+static void ExecuteAVXInstruction();
+static void ExecuteAVX2Instruction();
+static void ExecuteAVX512FInstruction();
+static void ExecuteAVX512DQInstruction();
+static void ExecuteAVX512IFMAInstruction();
+static void ExecuteAVX512PFInstruction();
+static void ExecuteAVX512ERInstruction();
+static void ExecuteAVX512CDInstruction();
+static void ExecuteAVX512BWInstruction();
+static void ExecuteAVX512VLInstruction();
+static void ExecuteAVX512VBMIInstruction();
+static void ExecutePREFETCHWT1Instruction();
+static void ExecuteSHAInstruction();
+static void ExecuteADXInstruction();
+static void ExecuteRDRANDInstruction();
+static void ExecuteRDSEEDInstruction();
+static void ExecutePCOMMITInstruction();
+static void ExecuteCLFLUSHOPTInstruction();
+static void ExecuteCLWBInstruction();
+
static void ExecuteFMAInstruction() {
}
@@ -58,82 +58,82 @@ static void ExecuteXSAVEInstruction() {
static void ExecuteOSXSAVEInstruction() {
}
-Y_UNIT_TEST_SUITE(TestCpuId) {
-#define DECLARE_TEST_HAVE_INSTRUCTION(name) \
+Y_UNIT_TEST_SUITE(TestCpuId) {
+#define DECLARE_TEST_HAVE_INSTRUCTION(name) \
Y_UNIT_TEST(Test##Have##name) { \
- if (NX86::Have##name()) { \
- Execute##name##Instruction(); \
- } \
+ if (NX86::Have##name()) { \
+ Execute##name##Instruction(); \
+ } \
}
Y_CPU_ID_ENUMERATE(DECLARE_TEST_HAVE_INSTRUCTION)
-#undef DECLARE_TEST_HAVE_INSTRUCTION
-
- Y_UNIT_TEST(TestSSE2) {
+#undef DECLARE_TEST_HAVE_INSTRUCTION
+
+ Y_UNIT_TEST(TestSSE2) {
#if defined(_x86_64_)
UNIT_ASSERT(NX86::HaveSSE2());
#endif
}
- Y_UNIT_TEST(TestCpuBrand) {
+ Y_UNIT_TEST(TestCpuBrand) {
ui32 store[12];
//Cout << CpuBrand(store) << Endl;;
UNIT_ASSERT(strlen(CpuBrand(store)) > 0);
}
-
- Y_UNIT_TEST(TestCachedAndNoncached) {
+
+ Y_UNIT_TEST(TestCachedAndNoncached) {
#define Y_DEF_NAME(X) UNIT_ASSERT_VALUES_EQUAL(NX86::Have##X(), NX86::CachedHave##X());
Y_CPU_ID_ENUMERATE(Y_DEF_NAME)
#undef Y_DEF_NAME
- }
+ }
}
-
-#if defined(_x86_64_)
+
+#if defined(_x86_64_)
#if defined(__GNUC__)
-void ExecuteSSEInstruction() {
+void ExecuteSSEInstruction() {
__asm__ __volatile__("xorps %%xmm0, %%xmm0\n"
:
:
: "xmm0");
-}
-
-void ExecuteSSE2Instruction() {
+}
+
+void ExecuteSSE2Instruction() {
__asm__ __volatile__("psrldq $0, %%xmm0\n"
:
:
: "xmm0");
-}
-
-void ExecuteSSE3Instruction() {
+}
+
+void ExecuteSSE3Instruction() {
__asm__ __volatile__("addsubpd %%xmm0, %%xmm0\n"
:
:
: "xmm0");
-}
-
-void ExecuteSSSE3Instruction() {
+}
+
+void ExecuteSSSE3Instruction() {
__asm__ __volatile__("psignb %%xmm0, %%xmm0\n"
:
:
: "xmm0");
-}
-
-void ExecuteSSE41Instruction() {
+}
+
+void ExecuteSSE41Instruction() {
__asm__ __volatile__("pmuldq %%xmm0, %%xmm0\n"
:
:
: "xmm0");
-}
-
-void ExecuteSSE42Instruction() {
+}
+
+void ExecuteSSE42Instruction() {
__asm__ __volatile__("crc32 %%eax, %%eax\n"
:
:
: "eax");
-}
-
+}
+
void ExecuteF16CInstruction() {
__asm__ __volatile__("vcvtph2ps %%xmm0, %%ymm0\n"
:
@@ -141,34 +141,34 @@ void ExecuteF16CInstruction() {
: "xmm0");
}
-void ExecuteAVXInstruction() {
+void ExecuteAVXInstruction() {
__asm__ __volatile__("vzeroupper\n"
:
:
: "xmm0");
-}
-
-void ExecuteAVX2Instruction() {
+}
+
+void ExecuteAVX2Instruction() {
__asm__ __volatile__("vpunpcklbw %%ymm0, %%ymm0, %%ymm0\n"
:
:
: "xmm0");
-}
-
-void ExecutePOPCNTInstruction() {
+}
+
+void ExecutePOPCNTInstruction() {
__asm__ __volatile__("popcnt %%eax, %%eax\n"
:
:
: "eax");
-}
-
-void ExecuteBMI1Instruction() {
+}
+
+void ExecuteBMI1Instruction() {
__asm__ __volatile__("tzcnt %%eax, %%eax\n"
:
:
: "eax");
-}
-
+}
+
void ExecuteBMI2Instruction() {
__asm__ __volatile__("pdep %%rax, %%rdi, %%rax\n"
:
@@ -183,268 +183,268 @@ void ExecutePCLMULInstruction() {
: "xmm0");
}
-void ExecuteAESInstruction() {
+void ExecuteAESInstruction() {
__asm__ __volatile__("aesimc %%xmm0, %%xmm0\n"
:
:
: "xmm0");
-}
-
-void ExecuteAVX512FInstruction() {
-}
-
-void ExecuteAVX512DQInstruction() {
-}
-
-void ExecuteAVX512IFMAInstruction() {
-}
-
-void ExecuteAVX512PFInstruction() {
-}
-
-void ExecuteAVX512ERInstruction() {
-}
-
-void ExecuteAVX512CDInstruction() {
-}
-
-void ExecuteAVX512BWInstruction() {
-}
-
-void ExecuteAVX512VLInstruction() {
-}
-
-void ExecuteAVX512VBMIInstruction() {
-}
-
-void ExecutePREFETCHWT1Instruction() {
-}
-
-void ExecuteSHAInstruction() {
+}
+
+void ExecuteAVX512FInstruction() {
+}
+
+void ExecuteAVX512DQInstruction() {
+}
+
+void ExecuteAVX512IFMAInstruction() {
+}
+
+void ExecuteAVX512PFInstruction() {
+}
+
+void ExecuteAVX512ERInstruction() {
+}
+
+void ExecuteAVX512CDInstruction() {
+}
+
+void ExecuteAVX512BWInstruction() {
+}
+
+void ExecuteAVX512VLInstruction() {
+}
+
+void ExecuteAVX512VBMIInstruction() {
+}
+
+void ExecutePREFETCHWT1Instruction() {
+}
+
+void ExecuteSHAInstruction() {
__asm__ __volatile__("sha1msg1 %%xmm0, %%xmm0\n"
:
:
: "xmm0");
-}
-
-void ExecuteADXInstruction() {
+}
+
+void ExecuteADXInstruction() {
__asm__ __volatile__("adcx %%eax, %%eax\n"
:
:
: "eax");
-}
-
-void ExecuteRDRANDInstruction() {
+}
+
+void ExecuteRDRANDInstruction() {
__asm__ __volatile__("rdrand %%eax"
:
:
: "eax");
-}
-
-void ExecuteRDSEEDInstruction() {
+}
+
+void ExecuteRDSEEDInstruction() {
__asm__ __volatile__("rdseed %%eax"
:
:
: "eax");
-}
-
-void ExecutePCOMMITInstruction() {
-}
-
-void ExecuteCLFLUSHOPTInstruction() {
-}
-
-void ExecuteCLWBInstruction() {
-}
-
+}
+
+void ExecutePCOMMITInstruction() {
+}
+
+void ExecuteCLFLUSHOPTInstruction() {
+}
+
+void ExecuteCLWBInstruction() {
+}
+
#elif defined(_MSC_VER)
-void ExecuteSSEInstruction() {
-}
-
-void ExecuteSSE2Instruction() {
-}
-
-void ExecuteSSE3Instruction() {
-}
-
-void ExecuteSSSE3Instruction() {
-}
-
-void ExecuteSSE41Instruction() {
-}
-
-void ExecuteSSE42Instruction() {
-}
-
+void ExecuteSSEInstruction() {
+}
+
+void ExecuteSSE2Instruction() {
+}
+
+void ExecuteSSE3Instruction() {
+}
+
+void ExecuteSSSE3Instruction() {
+}
+
+void ExecuteSSE41Instruction() {
+}
+
+void ExecuteSSE42Instruction() {
+}
+
void ExecuteF16CInstruction() {
}
-void ExecuteAVXInstruction() {
-}
-
-void ExecuteAVX2Instruction() {
-}
-
-void ExecutePOPCNTInstruction() {
-}
-
-void ExecuteBMI1Instruction() {
-}
-
+void ExecuteAVXInstruction() {
+}
+
+void ExecuteAVX2Instruction() {
+}
+
+void ExecutePOPCNTInstruction() {
+}
+
+void ExecuteBMI1Instruction() {
+}
+
void ExecuteBMI2Instruction() {
}
void ExecutePCLMULInstruction() {
}
-void ExecuteAESInstruction() {
-}
-
-void ExecuteAVX512FInstruction() {
-}
-
-void ExecuteAVX512DQInstruction() {
-}
-
-void ExecuteAVX512IFMAInstruction() {
-}
-
-void ExecuteAVX512PFInstruction() {
-}
-
-void ExecuteAVX512ERInstruction() {
-}
-
-void ExecuteAVX512CDInstruction() {
-}
-
-void ExecuteAVX512BWInstruction() {
-}
-
-void ExecuteAVX512VLInstruction() {
-}
-
-void ExecuteAVX512VBMIInstruction() {
-}
-
-void ExecutePREFETCHWT1Instruction() {
-}
-
-void ExecuteSHAInstruction() {
-}
-
-void ExecuteADXInstruction() {
-}
-
-void ExecuteRDRANDInstruction() {
-}
-
-void ExecuteRDSEEDInstruction() {
-}
-
-void ExecutePCOMMITInstruction() {
-}
-
-void ExecuteCLFLUSHOPTInstruction() {
-}
-
-void ExecuteCLWBInstruction() {
-}
-
+void ExecuteAESInstruction() {
+}
+
+void ExecuteAVX512FInstruction() {
+}
+
+void ExecuteAVX512DQInstruction() {
+}
+
+void ExecuteAVX512IFMAInstruction() {
+}
+
+void ExecuteAVX512PFInstruction() {
+}
+
+void ExecuteAVX512ERInstruction() {
+}
+
+void ExecuteAVX512CDInstruction() {
+}
+
+void ExecuteAVX512BWInstruction() {
+}
+
+void ExecuteAVX512VLInstruction() {
+}
+
+void ExecuteAVX512VBMIInstruction() {
+}
+
+void ExecutePREFETCHWT1Instruction() {
+}
+
+void ExecuteSHAInstruction() {
+}
+
+void ExecuteADXInstruction() {
+}
+
+void ExecuteRDRANDInstruction() {
+}
+
+void ExecuteRDSEEDInstruction() {
+}
+
+void ExecutePCOMMITInstruction() {
+}
+
+void ExecuteCLFLUSHOPTInstruction() {
+}
+
+void ExecuteCLWBInstruction() {
+}
+
#else
#error "unknown compiler"
#endif
-#else
-void ExecuteSSEInstruction() {
-}
-
-void ExecuteSSE2Instruction() {
-}
-
-void ExecuteSSE3Instruction() {
-}
-
-void ExecuteSSSE3Instruction() {
-}
-
-void ExecuteSSE41Instruction() {
-}
-
-void ExecuteSSE42Instruction() {
-}
-
+#else
+void ExecuteSSEInstruction() {
+}
+
+void ExecuteSSE2Instruction() {
+}
+
+void ExecuteSSE3Instruction() {
+}
+
+void ExecuteSSSE3Instruction() {
+}
+
+void ExecuteSSE41Instruction() {
+}
+
+void ExecuteSSE42Instruction() {
+}
+
void ExecuteF16CInstruction() {
}
-void ExecuteAVXInstruction() {
-}
-
-void ExecuteAVX2Instruction() {
-}
-
-void ExecutePOPCNTInstruction() {
-}
-
-void ExecuteBMI1Instruction() {
-}
-
+void ExecuteAVXInstruction() {
+}
+
+void ExecuteAVX2Instruction() {
+}
+
+void ExecutePOPCNTInstruction() {
+}
+
+void ExecuteBMI1Instruction() {
+}
+
void ExecuteBMI2Instruction() {
}
void ExecutePCLMULInstruction() {
}
-void ExecuteAESInstruction() {
-}
-
-void ExecuteAVX512FInstruction() {
-}
-
-void ExecuteAVX512DQInstruction() {
-}
-
-void ExecuteAVX512IFMAInstruction() {
-}
-
-void ExecuteAVX512PFInstruction() {
-}
-
-void ExecuteAVX512ERInstruction() {
-}
-
-void ExecuteAVX512CDInstruction() {
-}
-
-void ExecuteAVX512BWInstruction() {
-}
-
-void ExecuteAVX512VLInstruction() {
-}
-
-void ExecuteAVX512VBMIInstruction() {
-}
-
-void ExecutePREFETCHWT1Instruction() {
-}
-
-void ExecuteSHAInstruction() {
-}
-
-void ExecuteADXInstruction() {
-}
-
-void ExecuteRDRANDInstruction() {
-}
-
-void ExecuteRDSEEDInstruction() {
-}
-
-void ExecutePCOMMITInstruction() {
-}
-
-void ExecuteCLFLUSHOPTInstruction() {
-}
-
-void ExecuteCLWBInstruction() {
-}
-#endif
+void ExecuteAESInstruction() {
+}
+
+void ExecuteAVX512FInstruction() {
+}
+
+void ExecuteAVX512DQInstruction() {
+}
+
+void ExecuteAVX512IFMAInstruction() {
+}
+
+void ExecuteAVX512PFInstruction() {
+}
+
+void ExecuteAVX512ERInstruction() {
+}
+
+void ExecuteAVX512CDInstruction() {
+}
+
+void ExecuteAVX512BWInstruction() {
+}
+
+void ExecuteAVX512VLInstruction() {
+}
+
+void ExecuteAVX512VBMIInstruction() {
+}
+
+void ExecutePREFETCHWT1Instruction() {
+}
+
+void ExecuteSHAInstruction() {
+}
+
+void ExecuteADXInstruction() {
+}
+
+void ExecuteRDRANDInstruction() {
+}
+
+void ExecuteRDSEEDInstruction() {
+}
+
+void ExecutePCOMMITInstruction() {
+}
+
+void ExecuteCLFLUSHOPTInstruction() {
+}
+
+void ExecuteCLWBInstruction() {
+}
+#endif
diff --git a/util/system/datetime.cpp b/util/system/datetime.cpp
index 5bb9716fbb..b07b50679a 100644
--- a/util/system/datetime.cpp
+++ b/util/system/datetime.cpp
@@ -17,12 +17,12 @@
#define Y_HAS_CLOCK_GETTIME
#endif
-static ui64 ToMicroSeconds(const struct timeval& tv) {
+static ui64 ToMicroSeconds(const struct timeval& tv) {
return (ui64)tv.tv_sec * 1000000 + (ui64)tv.tv_usec;
}
#if defined(_win_)
-static ui64 ToMicroSeconds(const FILETIME& ft) {
+static ui64 ToMicroSeconds(const FILETIME& ft) {
return (((ui64)ft.dwHighDateTime << 32) + (ui64)ft.dwLowDateTime) / (ui64)10;
}
#elif defined(Y_HAS_CLOCK_GETTIME)
@@ -31,9 +31,9 @@ static ui64 ToMicroSeconds(const struct timespec& ts) {
}
#endif
-ui64 MicroSeconds() noexcept {
+ui64 MicroSeconds() noexcept {
struct timeval tv;
- gettimeofday(&tv, nullptr);
+ gettimeofday(&tv, nullptr);
return ToMicroSeconds(tv);
}
@@ -48,7 +48,7 @@ ui64 ThreadCPUUserTime() noexcept {
#endif
}
-ui64 ThreadCPUSystemTime() noexcept {
+ui64 ThreadCPUSystemTime() noexcept {
#if defined(_win_)
FILETIME creationTime, exitTime, kernelTime, userTime;
GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime, &userTime);
@@ -58,7 +58,7 @@ ui64 ThreadCPUSystemTime() noexcept {
#endif
}
-ui64 ThreadCPUTime() noexcept {
+ui64 ThreadCPUTime() noexcept {
#if defined(_win_)
FILETIME creationTime, exitTime, kernelTime, userTime;
GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime, &userTime);
@@ -72,13 +72,13 @@ ui64 ThreadCPUTime() noexcept {
#endif
}
-ui32 Seconds() noexcept {
+ui32 Seconds() noexcept {
struct timeval tv;
- gettimeofday(&tv, nullptr);
+ gettimeofday(&tv, nullptr);
return tv.tv_sec;
}
-void NanoSleep(ui64 ns) noexcept {
+void NanoSleep(ui64 ns) noexcept {
#if defined(_win_)
Sleep(ns / 1000000);
#else
@@ -88,7 +88,7 @@ void NanoSleep(ui64 ns) noexcept {
req.tv_nsec = ns % NS;
struct timespec left;
while (nanosleep(&req, &left) < 0) {
- Y_ASSERT(errno == EINTR);
+ Y_ASSERT(errno == EINTR);
req = left;
}
#endif
diff --git a/util/system/datetime.h b/util/system/datetime.h
index 21f127d1d5..aa009974e0 100644
--- a/util/system/datetime.h
+++ b/util/system/datetime.h
@@ -16,7 +16,7 @@
/// for handy datetime utilities include util/datetime/base.h
/// Current time in microseconds since epoch
-ui64 MicroSeconds() noexcept;
+ui64 MicroSeconds() noexcept;
/// Current time in milliseconds since epoch
inline ui64 MilliSeconds() {
return MicroSeconds() / ui64(1000);
@@ -26,13 +26,13 @@ inline ui64 millisec() {
return MilliSeconds();
}
/// Current time in seconds since epoch
-ui32 Seconds() noexcept;
+ui32 Seconds() noexcept;
///Current thread time in microseconds
-ui64 ThreadCPUUserTime() noexcept;
-ui64 ThreadCPUSystemTime() noexcept;
-ui64 ThreadCPUTime() noexcept;
+ui64 ThreadCPUUserTime() noexcept;
+ui64 ThreadCPUSystemTime() noexcept;
+ui64 ThreadCPUTime() noexcept;
-void NanoSleep(ui64 ns) noexcept;
+void NanoSleep(ui64 ns) noexcept;
// GetCycleCount guarantees to return synchronous values on different cores
// and provide constant rate only on modern Intel and AMD processors
@@ -41,7 +41,7 @@ void NanoSleep(ui64 ns) noexcept;
// with preceding instructions
// PERFORMANCE: rdtsc - 15 cycles per call , rdtscp - 19 cycles per call
// WARNING: following instruction can be executed out-of-order
-Y_FORCE_INLINE ui64 GetCycleCount() noexcept {
+Y_FORCE_INLINE ui64 GetCycleCount() noexcept {
#if defined(_MSC_VER)
// Generates the rdtscp instruction, which returns the processor time stamp.
// The processor time stamp records the number of clock cycles since the last reset.
diff --git a/util/system/defaults.h b/util/system/defaults.h
index b2b5756b34..dcd7abea38 100644
--- a/util/system/defaults.h
+++ b/util/system/defaults.h
@@ -74,7 +74,7 @@
#endif
#include "compiler.h"
-
+
#ifdef _win_
#include <malloc.h>
#elif defined(_sun_)
@@ -93,33 +93,33 @@ constexpr bool Y_IS_DEBUG_BUILD = true;
#endif
#endif
-/**
- * @def Y_ARRAY_SIZE
- *
- * This macro is needed to get number of elements in a statically allocated fixed size array. The
- * expression is a compile-time constant and therefore can be used in compile time computations.
- *
- * @code
- * enum ENumbers {
- * EN_ONE,
- * EN_TWO,
- * EN_SIZE
- * }
- *
- * const char* NAMES[] = {
- * "one",
- * "two"
- * }
- *
- * static_assert(Y_ARRAY_SIZE(NAMES) == EN_SIZE, "you should define `NAME` for each enumeration");
- * @endcode
- *
- * This macro also catches type errors. If you see a compiler error like "warning: division by zero
- * is undefined" when using `Y_ARRAY_SIZE` then you are probably giving it a pointer.
- *
- * Since all of our code is expected to work on a 64 bit platform where pointers are 8 bytes we may
- * falsefully accept pointers to types of sizes that are divisors of 8 (1, 2, 4 and 8).
- */
+/**
+ * @def Y_ARRAY_SIZE
+ *
+ * This macro is needed to get number of elements in a statically allocated fixed size array. The
+ * expression is a compile-time constant and therefore can be used in compile time computations.
+ *
+ * @code
+ * enum ENumbers {
+ * EN_ONE,
+ * EN_TWO,
+ * EN_SIZE
+ * }
+ *
+ * const char* NAMES[] = {
+ * "one",
+ * "two"
+ * }
+ *
+ * static_assert(Y_ARRAY_SIZE(NAMES) == EN_SIZE, "you should define `NAME` for each enumeration");
+ * @endcode
+ *
+ * This macro also catches type errors. If you see a compiler error like "warning: division by zero
+ * is undefined" when using `Y_ARRAY_SIZE` then you are probably giving it a pointer.
+ *
+ * Since all of our code is expected to work on a 64 bit platform where pointers are 8 bytes we may
+ * falsefully accept pointers to types of sizes that are divisors of 8 (1, 2, 4 and 8).
+ */
#if defined(__cplusplus)
#include <util/generic/array_size.h>
#else
@@ -128,11 +128,11 @@ constexpr bool Y_IS_DEBUG_BUILD = true;
((sizeof(arr) / sizeof((arr)[0])) / static_cast<size_t>(!(sizeof(arr) % sizeof((arr)[0]))))
#endif
-#undef Y_ARRAY_BEGIN
-#define Y_ARRAY_BEGIN(arr) (arr)
+#undef Y_ARRAY_BEGIN
+#define Y_ARRAY_BEGIN(arr) (arr)
-#undef Y_ARRAY_END
-#define Y_ARRAY_END(arr) ((arr) + Y_ARRAY_SIZE(arr))
+#undef Y_ARRAY_END
+#define Y_ARRAY_END(arr) ((arr) + Y_ARRAY_SIZE(arr))
/**
* Concatenates two symbols, even if one of them is itself a macro.
@@ -148,7 +148,7 @@ constexpr bool Y_IS_DEBUG_BUILD = true;
#define Y_GENERATE_UNIQUE_ID(N) Y_CAT(N, __COUNTER__)
#endif
-#if !defined(Y_GENERATE_UNIQUE_ID)
+#if !defined(Y_GENERATE_UNIQUE_ID)
#define Y_GENERATE_UNIQUE_ID(N) Y_CAT(N, __LINE__)
#endif
diff --git a/util/system/direct_io.cpp b/util/system/direct_io.cpp
index 73a55007a0..f59c54b0cb 100644
--- a/util/system/direct_io.cpp
+++ b/util/system/direct_io.cpp
@@ -19,7 +19,7 @@ namespace {
#ifdef _linux_
utsname sysInfo;
- Y_VERIFY(!uname(&sysInfo), "Error while call uname: %s", LastSystemErrorText());
+ Y_VERIFY(!uname(&sysInfo), "Error while call uname: %s", LastSystemErrorText());
TStringBuf release(sysInfo.release);
release = release.substr(0, release.find_first_not_of(".0123456789"));
diff --git a/util/system/direct_io_ut.cpp b/util/system/direct_io_ut.cpp
index 96e2de6637..839c3de7ca 100644
--- a/util/system/direct_io_ut.cpp
+++ b/util/system/direct_io_ut.cpp
@@ -9,8 +9,8 @@
static const char* FileName_("./test.file");
-Y_UNIT_TEST_SUITE(TDirectIoTestSuite) {
- Y_UNIT_TEST(TestDirectFile) {
+Y_UNIT_TEST_SUITE(TDirectIoTestSuite) {
+ Y_UNIT_TEST(TestDirectFile) {
TDirectIOBufferedFile file(FileName_, RdWr | Direct | Seq | CreateAlways, 1 << 15);
TVector<ui64> data((1 << 15) + 1);
TVector<ui64> readResult(data.size());
diff --git a/util/system/dynlib.cpp b/util/system/dynlib.cpp
index 3ce77e5540..9d2541c25f 100644
--- a/util/system/dynlib.cpp
+++ b/util/system/dynlib.cpp
@@ -33,7 +33,7 @@ inline TString DLLERR() {
#ifdef _win32_
char* msg = 0;
DWORD cnt = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (char*)&msg, 0, nullptr);
+ nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (char*)&msg, 0, nullptr);
if (!msg)
return "DLLERR() unknown error";
while (cnt && isspace(msg[cnt - 1]))
@@ -80,7 +80,7 @@ public:
inline void* Sym(const char* name) {
void* symbol = SymOptional(name);
- if (symbol == nullptr) {
+ if (symbol == nullptr) {
ythrow yexception() << DLLERR().data();
}
@@ -115,7 +115,7 @@ void TDynamicLibrary::Close() noexcept {
void* TDynamicLibrary::SymOptional(const char* name) noexcept {
if (!IsLoaded()) {
- return nullptr;
+ return nullptr;
}
return Impl_->SymOptional(name);
diff --git a/util/system/dynlib.h b/util/system/dynlib.h
index 13ce0bf4b5..66eaf4a5c1 100644
--- a/util/system/dynlib.h
+++ b/util/system/dynlib.h
@@ -5,8 +5,8 @@
#include <util/generic/ptr.h>
#include <util/generic/string.h>
-#define Y_GET_FUNC(dll, name) FUNC_##name((dll).Sym(#name))
-#define Y_GET_FUNC_OPTIONAL(dll, name) FUNC_##name((dll).SymOptional(#name))
+#define Y_GET_FUNC(dll, name) FUNC_##name((dll).Sym(#name))
+#define Y_GET_FUNC_OPTIONAL(dll, name) FUNC_##name((dll).SymOptional(#name))
#ifdef _win32_
#define DEFAULT_DLLOPEN_FLAGS 0
diff --git a/util/system/env.cpp b/util/system/env.cpp
index 97cdd2cb31..ead9b566a5 100644
--- a/util/system/env.cpp
+++ b/util/system/env.cpp
@@ -11,16 +11,16 @@
#include <cstdlib>
#endif
-/**
+/**
* On Windows there may be many copies of enviroment variables, there at least two known, one is
* manipulated by Win32 API, another by C runtime, so we must be consistent in the choice of
- * functions used to manipulate them.
- *
- * Relevant links:
- * - http://bugs.python.org/issue16633
+ * functions used to manipulate them.
+ *
+ * Relevant links:
+ * - http://bugs.python.org/issue16633
* - https://a.yandex-team.ru/review/108892/details
- */
-
+ */
+
TString GetEnv(const TString& key, const TString& def) {
#ifdef _win_
size_t len = GetEnvironmentVariableA(key.data(), nullptr, 0);
diff --git a/util/system/env.h b/util/system/env.h
index 7f4c3cc70f..e2ccdd1e95 100644
--- a/util/system/env.h
+++ b/util/system/env.h
@@ -2,31 +2,31 @@
#include <util/generic/string.h>
-/**
- * Search the environment list provided by the host environment for associated variable.
- *
+/**
+ * Search the environment list provided by the host environment for associated variable.
+ *
* @param key String identifying the name of the environmental variable to look for
* @param def String that returns if environmental variable not found by key
- *
- * @return String that is associated with the matched environment variable or empty string if
- * such variable is missing.
- *
+ *
+ * @return String that is associated with the matched environment variable or empty string if
+ * such variable is missing.
+ *
* @note Use it only in pair with `SetEnv` as there may be inconsistency in their behaviour
- * otherwise.
- * @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized.
- * @see SetEnv
- */
+ * otherwise.
+ * @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized.
+ * @see SetEnv
+ */
TString GetEnv(const TString& key, const TString& def = TString());
-
-/**
- * Add or change environment variable provided by the host environment.
- *
- * @key String identifying the name of the environment variable to set or change
- * @value Value to assign
-
+
+/**
+ * Add or change environment variable provided by the host environment.
+ *
+ * @key String identifying the name of the environment variable to set or change
+ * @value Value to assign
+
* @note Use it only in pair with `GetEnv` as there may be inconsistency in their behaviour
- * otherwise.
- * @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized.
- * @see GetEnv
- */
+ * otherwise.
+ * @note Calls to `GetEnv` and `SetEnv` from different threads must be synchronized.
+ * @see GetEnv
+ */
void SetEnv(const TString& key, const TString& value);
diff --git a/util/system/env_ut.cpp b/util/system/env_ut.cpp
index 865acf8e12..e03cc01658 100644
--- a/util/system/env_ut.cpp
+++ b/util/system/env_ut.cpp
@@ -3,19 +3,19 @@
#include <util/generic/string.h>
#include "env.h"
-Y_UNIT_TEST_SUITE(EnvTest) {
- Y_UNIT_TEST(GetSetEnvTest) {
+Y_UNIT_TEST_SUITE(EnvTest) {
+ Y_UNIT_TEST(GetSetEnvTest) {
TString key = "util_GETENV_TestVar";
TString value = "Some value for env var";
TString def = "Some default value for env var";
- // first of all, it should be clear
+ // first of all, it should be clear
UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), TString());
UNIT_ASSERT_VALUES_EQUAL(GetEnv(key, def), def);
- SetEnv(key, value);
- // set and see what value we get here
- UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), value);
+ SetEnv(key, value);
+ // set and see what value we get here
+ UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), value);
UNIT_ASSERT_VALUES_EQUAL(GetEnv(key, def), value);
- // set empty value
+ // set empty value
SetEnv(key, TString());
UNIT_ASSERT_VALUES_EQUAL(GetEnv(key), TString());
@@ -27,5 +27,5 @@ Y_UNIT_TEST_SUITE(EnvTest) {
UNIT_ASSERT_VALUES_EQUAL(GetEnv(longKey), longValue);
SetEnv(longKey, TString());
UNIT_ASSERT_VALUES_EQUAL(GetEnv(longKey), TString());
- }
+ }
}
diff --git a/util/system/error.cpp b/util/system/error.cpp
index b3be00e7fe..f778ec42cb 100644
--- a/util/system/error.cpp
+++ b/util/system/error.cpp
@@ -1,7 +1,7 @@
#include "tls.h"
#include "error.h"
-#include <util/string/strip.h>
+#include <util/string/strip.h>
#include <util/generic/strfcpy.h>
#include <cerrno>
diff --git a/util/system/event.cpp b/util/system/event.cpp
index 36ba4b7bcd..79b3cdb291 100644
--- a/util/system/event.cpp
+++ b/util/system/event.cpp
@@ -16,7 +16,7 @@ class TSystemEvent::TEvImpl: public TAtomicRefCount<TSystemEvent::TEvImpl> {
public:
#ifdef _win_
inline TEvImpl(ResetMode rmode) {
- cond = CreateEvent(nullptr, rmode == rManual ? true : false, false, nullptr);
+ cond = CreateEvent(nullptr, rmode == rManual ? true : false, false, nullptr);
}
inline ~TEvImpl() {
diff --git a/util/system/event_ut.cpp b/util/system/event_ut.cpp
index 650ba4641a..2506cb7a91 100644
--- a/util/system/event_ut.cpp
+++ b/util/system/event_ut.cpp
@@ -82,8 +82,8 @@ namespace {
}
-Y_UNIT_TEST_SUITE(EventTest) {
- Y_UNIT_TEST(WaitAndSignalTest) {
+Y_UNIT_TEST_SUITE(EventTest) {
+ Y_UNIT_TEST(WaitAndSignalTest) {
TSharedData data;
TThreadPool queue;
queue.Start(5);
@@ -95,7 +95,7 @@ Y_UNIT_TEST_SUITE(EventTest) {
UNIT_ASSERT(!data.failed);
}
- Y_UNIT_TEST(ConcurrentSignalAndWaitTest) {
+ Y_UNIT_TEST(ConcurrentSignalAndWaitTest) {
// test for problem detected by thread-sanitizer (signal/wait race) SEARCH-2113
const size_t limit = 200;
TManualEvent event[limit];
@@ -113,7 +113,7 @@ Y_UNIT_TEST_SUITE(EventTest) {
}
/** Test for a problem: http://nga.at.yandex-team.ru/5772 */
- Y_UNIT_TEST(DestructorBeforeSignalFinishTest) {
+ Y_UNIT_TEST(DestructorBeforeSignalFinishTest) {
return;
TVector<THolder<IObjectInQueue>> tasks;
for (size_t i = 0; i < 1000; ++i) {
diff --git a/util/system/execpath.cpp b/util/system/execpath.cpp
index 10f08cea3e..33198af58b 100644
--- a/util/system/execpath.cpp
+++ b/util/system/execpath.cpp
@@ -39,7 +39,7 @@ static inline bool GoodPath(const TString& path) {
static inline int FreeBSDSysCtl(int* mib, size_t mibSize, TTempBuf& res) {
for (size_t i = 0; i < 2; ++i) {
size_t cb = res.Size();
- if (sysctl(mib, mibSize, res.Data(), &cb, nullptr, 0) == 0) {
+ if (sysctl(mib, mibSize, res.Data(), &cb, nullptr, 0) == 0) {
res.Proceed(cb);
return 0;
} else if (errno == ENOMEM) {
@@ -54,7 +54,7 @@ static inline int FreeBSDSysCtl(int* mib, size_t mibSize, TTempBuf& res) {
static inline TString FreeBSDGetExecPath() {
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
TTempBuf buf;
- int r = FreeBSDSysCtl(mib, Y_ARRAY_SIZE(mib), buf);
+ int r = FreeBSDSysCtl(mib, Y_ARRAY_SIZE(mib), buf);
if (r == 0) {
return TString(buf.Data(), buf.Filled() - 1);
} else if (r == ENOTSUP) { // older FreeBSD version
@@ -73,7 +73,7 @@ static inline TString FreeBSDGetExecPath() {
static inline TString FreeBSDGetArgv0() {
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ARGS, getpid()};
TTempBuf buf;
- int r = FreeBSDSysCtl(mib, Y_ARRAY_SIZE(mib), buf);
+ int r = FreeBSDSysCtl(mib, Y_ARRAY_SIZE(mib), buf);
if (r == 0) {
return TString(buf.Data());
} else if (r == ENOTSUP) {
@@ -118,7 +118,7 @@ static TString GetExecPathImpl() {
#elif defined(_win_)
TTempBuf execNameBuf;
for (;;) {
- DWORD r = GetModuleFileName(nullptr, execNameBuf.Data(), execNameBuf.Size());
+ DWORD r = GetModuleFileName(nullptr, execNameBuf.Data(), execNameBuf.Size());
if (r == execNameBuf.Size()) {
execNameBuf = TTempBuf(execNameBuf.Size() * 2);
} else if (r == 0) {
diff --git a/util/system/execpath_ut.cpp b/util/system/execpath_ut.cpp
index d1d23fcf72..16b01466f5 100644
--- a/util/system/execpath_ut.cpp
+++ b/util/system/execpath_ut.cpp
@@ -5,8 +5,8 @@
#include "platform.h"
#include <util/folder/dirut.h>
-Y_UNIT_TEST_SUITE(TExecPathTest) {
- Y_UNIT_TEST(TestIt) {
+Y_UNIT_TEST_SUITE(TExecPathTest) {
+ Y_UNIT_TEST(TestIt) {
TString execPath = GetExecPath();
TString persistentExecPath = GetPersistentExecPath();
diff --git a/util/system/fasttime.cpp b/util/system/fasttime.cpp
index 82f199e230..057a814f0a 100644
--- a/util/system/fasttime.cpp
+++ b/util/system/fasttime.cpp
@@ -31,7 +31,7 @@ namespace {
using TFunc = int (*)(struct timeval*, struct timezone*);
inline TSymbols()
- : Func(nullptr)
+ : Func(nullptr)
{
// not DEFAULT, cause library/cpp/gettimeofday
Func = reinterpret_cast<TFunc>(dlsym(RTLD_NEXT, "gettimeofday"));
@@ -52,7 +52,7 @@ namespace {
Zero(tv);
- Func(&tv, nullptr);
+ Func(&tv, nullptr);
return (((TTime)1000000) * (TTime)tv.tv_sec) + (TTime)tv.tv_usec;
}
@@ -64,7 +64,7 @@ namespace {
"/lib/libc.so.6",
};
- for (auto& lib : libs) {
+ for (auto& lib : libs) {
try {
return MakeHolder<TDynamicLibrary>(lib);
} catch (...) {
diff --git a/util/system/file.cpp b/util/system/file.cpp
index 0ba1a89062..4a261d020c 100644
--- a/util/system/file.cpp
+++ b/util/system/file.cpp
@@ -274,8 +274,8 @@ bool TFileHandle::Close() noexcept {
isOk = (::CloseHandle(Fd_) != 0);
}
if (!isOk) {
- Y_VERIFY(GetLastError() != ERROR_INVALID_HANDLE,
- "must not quietly close invalid handle");
+ Y_VERIFY(GetLastError() != ERROR_INVALID_HANDLE,
+ "must not quietly close invalid handle");
}
#elif defined(_unix_)
if (Fd_ != INVALID_FHANDLE) {
@@ -285,7 +285,7 @@ bool TFileHandle::Close() noexcept {
// Do not quietly close bad descriptor,
// because often it means double close
// that is disasterous
- Y_VERIFY(errno != EBADF, "must not quietly close bad descriptor: fd=%d", int(Fd_));
+ Y_VERIFY(errno != EBADF, "must not quietly close bad descriptor: fd=%d", int(Fd_));
}
#else
#error unsupported platform
@@ -1288,15 +1288,15 @@ bool PosixDisableReadAhead(FHANDLE fileHandle, void* addr) noexcept {
#if HAVE_POSIX_FADVISE
#if defined(_linux_)
- Y_UNUSED(fileHandle);
+ Y_UNUSED(fileHandle);
ret = madvise(addr, 0, MADV_RANDOM); // according to klamm@ posix_fadvise does not work under linux, madvise does work
#else
- Y_UNUSED(addr);
+ Y_UNUSED(addr);
ret = ::posix_fadvise(fileHandle, 0, 0, POSIX_FADV_RANDOM);
#endif
#else
- Y_UNUSED(fileHandle);
- Y_UNUSED(addr);
+ Y_UNUSED(fileHandle);
+ Y_UNUSED(addr);
#endif
return ret == 0;
}
diff --git a/util/system/file_ut.cpp b/util/system/file_ut.cpp
index 22a2f5c625..941e6a50f3 100644
--- a/util/system/file_ut.cpp
+++ b/util/system/file_ut.cpp
@@ -113,7 +113,7 @@ public:
const TString data = TUnbufferedFileInput(tmp.Name()).ReadAll();
UNIT_ASSERT_EQUAL(data.length(), 12);
- UNIT_ASSERT(data.StartsWith("12345"));
+ UNIT_ASSERT(data.StartsWith("12345"));
}
};
@@ -202,7 +202,7 @@ void TFileTest::TestRW() {
void TFileTest::TestLocale() {
#ifdef _unix_
- const char* loc = setlocale(LC_CTYPE, nullptr);
+ const char* loc = setlocale(LC_CTYPE, nullptr);
setlocale(LC_CTYPE, "ru_RU.UTF-8");
#endif
TFile f("Имя.txt", CreateNew);
@@ -405,8 +405,8 @@ UNIT_ASSERT_VALUES_EQUAL(file.CountCache(0, 12345), -1);
#endif
}
-Y_UNIT_TEST_SUITE(TTestDecodeOpenMode) {
- Y_UNIT_TEST(It) {
+Y_UNIT_TEST_SUITE(TTestDecodeOpenMode) {
+ Y_UNIT_TEST(It) {
UNIT_ASSERT_VALUES_EQUAL("0", DecodeOpenMode(0));
UNIT_ASSERT_VALUES_EQUAL("RdOnly", DecodeOpenMode(RdOnly));
UNIT_ASSERT_VALUES_EQUAL("RdWr", DecodeOpenMode(RdWr));
diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp
index 45733c7422..7454a4cb94 100644
--- a/util/system/filemap.cpp
+++ b/util/system/filemap.cpp
@@ -128,12 +128,12 @@ class TMemoryMap::TImpl: public TAtomicRefCount<TImpl> {
public:
inline void CreateMapping() {
#if defined(_win_)
- Mapping_ = nullptr;
+ Mapping_ = nullptr;
if (Length_) {
- Mapping_ = CreateFileMapping(File_.GetHandle(), nullptr,
+ Mapping_ = CreateFileMapping(File_.GetHandle(), nullptr,
(Mode_ & oAccessMask) == TFileMap::oRdWr ? PAGE_READWRITE : PAGE_READONLY,
- (DWORD)(Length_ >> 32), (DWORD)(Length_ & 0xFFFFFFFF), nullptr);
- if (Mapping_ == nullptr) {
+ (DWORD)(Length_ >> 32), (DWORD)(Length_ & 0xFFFFFFFF), nullptr);
+ if (Mapping_ == nullptr) {
ythrow yexception() << "Can't create file mapping of '" << DbgName_ << "': " << LastSystemErrorText();
}
} else {
@@ -147,7 +147,7 @@ public:
ythrow yexception() << "Can't map " << (unsigned long)Length_ << " bytes of file '" << DbgName_ << "' at offset 0: " << LastSystemErrorText();
}
} else {
- PtrStart_ = nullptr;
+ PtrStart_ = nullptr;
}
#endif
}
@@ -209,7 +209,7 @@ public:
inline bool IsOpen() const noexcept {
return File_.IsOpen()
#if defined(_win_)
- && Mapping_ != nullptr
+ && Mapping_ != nullptr
#endif
;
}
@@ -247,15 +247,15 @@ public:
result.Ptr = mmap((caddr_t) nullptr, size, ModeToMmapProt(Mode_), ModeToMmapFlags(Mode_), File_.GetHandle(), base);
if (result.Ptr == (char*)(-1)) {
- result.Ptr = nullptr;
+ result.Ptr = nullptr;
}
#if defined(_unix_)
} else {
- result.Ptr = PtrStart_ ? static_cast<caddr_t>(PtrStart_) + base : nullptr;
+ result.Ptr = PtrStart_ ? static_cast<caddr_t>(PtrStart_) + base : nullptr;
}
#endif
#endif
- if (result.Ptr != nullptr || size == 0) { // allow map of size 0
+ if (result.Ptr != nullptr || size == 0) { // allow map of size 0
result.Size = size;
} else {
ythrow yexception() << "Can't map " << (unsigned long)size << " bytes at offset " << offset << " of '" << DbgName_ << "': " << LastSystemErrorText();
@@ -308,7 +308,7 @@ public:
#if defined(_win_)
if (Mapping_) {
::CloseHandle(Mapping_); // != FALSE
- Mapping_ = nullptr;
+ Mapping_ = nullptr;
}
#elif defined(_unix_)
if (PtrStart_) {
@@ -475,8 +475,8 @@ TFileMap::TFileMap(const TFileMap& fm) noexcept
}
void TFileMap::Flush(void* ptr, size_t size, bool sync) {
- Y_ASSERT(ptr >= Ptr());
- Y_ASSERT(static_cast<char*>(ptr) + size <= static_cast<char*>(Ptr()) + MappedSize());
+ Y_ASSERT(ptr >= Ptr());
+ Y_ASSERT(static_cast<char*>(ptr) + size <= static_cast<char*>(Ptr()) + MappedSize());
if (!Region_.IsMapped()) {
return;
@@ -530,11 +530,11 @@ void TFileMap::Precharge(size_t pos, size_t size) const {
}
TMappedAllocation::TMappedAllocation(size_t size, bool shared, void* addr)
- : Ptr_(nullptr)
+ : Ptr_(nullptr)
, Size_(0)
, Shared_(shared)
#if defined(_win_)
- , Mapping_(nullptr)
+ , Mapping_(nullptr)
#endif
{
if (size != 0) {
@@ -543,16 +543,16 @@ TMappedAllocation::TMappedAllocation(size_t size, bool shared, void* addr)
}
void* TMappedAllocation::Alloc(size_t size, void* addr) {
- assert(Ptr_ == nullptr);
+ assert(Ptr_ == nullptr);
#if defined(_win_)
(void)addr;
- Mapping_ = CreateFileMapping((HANDLE)-1, nullptr, PAGE_READWRITE, 0, size ? size : 1, nullptr);
+ Mapping_ = CreateFileMapping((HANDLE)-1, nullptr, PAGE_READWRITE, 0, size ? size : 1, nullptr);
Ptr_ = MapViewOfFile(Mapping_, FILE_MAP_WRITE, 0, 0, size ? size : 1);
#else
Ptr_ = mmap(addr, size, PROT_READ | PROT_WRITE, (Shared_ ? MAP_SHARED : MAP_PRIVATE) | MAP_ANON, -1, 0);
if (Ptr_ == (void*)MAP_FAILED) {
- Ptr_ = nullptr;
+ Ptr_ = nullptr;
}
#endif
if (Ptr_ != nullptr) {
@@ -568,11 +568,11 @@ void TMappedAllocation::Dealloc() {
#if defined(_win_)
UnmapViewOfFile(Ptr_);
CloseHandle(Mapping_);
- Mapping_ = nullptr;
+ Mapping_ = nullptr;
#else
munmap((caddr_t)Ptr_, Size_);
#endif
- Ptr_ = nullptr;
+ Ptr_ = nullptr;
Size_ = 0;
}
diff --git a/util/system/filemap.h b/util/system/filemap.h
index 262b5cd976..11be64bff4 100644
--- a/util/system/filemap.h
+++ b/util/system/filemap.h
@@ -26,15 +26,15 @@ struct TMemoryMapCommon {
}
inline void* MappedData() const noexcept {
- return Ptr ? (void*)((char*)Ptr + Head) : nullptr;
+ return Ptr ? (void*)((char*)Ptr + Head) : nullptr;
}
inline bool IsMapped() const noexcept {
- return Ptr != nullptr;
+ return Ptr != nullptr;
}
inline void Reset() noexcept {
- Ptr = nullptr;
+ Ptr = nullptr;
Size = 0;
Head = 0;
}
@@ -195,14 +195,14 @@ private:
public:
TFileMappedArray()
- : Ptr_(nullptr)
- , End_(nullptr)
+ : Ptr_(nullptr)
+ , End_(nullptr)
, Size_(0)
{
}
~TFileMappedArray() {
- Ptr_ = nullptr;
- End_ = nullptr;
+ Ptr_ = nullptr;
+ End_ = nullptr;
}
void Init(const char* name) {
DataHolder_.Reset(new TFileMap(name));
@@ -214,15 +214,15 @@ public:
}
void Term() {
DataHolder_.Destroy();
- Ptr_ = nullptr;
+ Ptr_ = nullptr;
Size_ = 0;
- End_ = nullptr;
+ End_ = nullptr;
}
void Precharge() {
DataHolder_->Precharge();
}
const T& operator[](size_t pos) const {
- Y_ASSERT(pos < size());
+ Y_ASSERT(pos < size());
return Ptr_[pos];
}
/// for STL compatibility only, Size() usage is recommended
@@ -289,7 +289,7 @@ private:
class TMappedAllocation: TMoveOnly {
public:
- TMappedAllocation(size_t size = 0, bool shared = false, void* addr = nullptr);
+ TMappedAllocation(size_t size = 0, bool shared = false, void* addr = nullptr);
~TMappedAllocation() {
Dealloc();
}
@@ -300,13 +300,13 @@ public:
this->swap(other);
return *this;
}
- void* Alloc(size_t size, void* addr = nullptr);
+ void* Alloc(size_t size, void* addr = nullptr);
void Dealloc();
void* Ptr() const {
return Ptr_;
}
char* Data(ui32 pos = 0) const {
- return (char*)(Ptr_ ? ((char*)Ptr_ + pos) : nullptr);
+ return (char*)(Ptr_ ? ((char*)Ptr_ + pos) : nullptr);
}
char* Begin() const noexcept {
return (char*)Ptr();
@@ -341,11 +341,11 @@ public:
Destroy();
}
T* Create(size_t siz) {
- Y_ASSERT(MappedSize() == 0 && Ptr() == nullptr);
+ Y_ASSERT(MappedSize() == 0 && Ptr() == nullptr);
T* arr = (T*)Alloc((sizeof(T) * siz));
if (!arr)
- return nullptr;
- Y_ASSERT(MappedSize() == sizeof(T) * siz);
+ return nullptr;
+ Y_ASSERT(MappedSize() == sizeof(T) * siz);
for (size_t n = 0; n < siz; n++)
new (&arr[n]) T();
return arr;
@@ -359,11 +359,11 @@ public:
}
}
T& operator[](size_t pos) {
- Y_ASSERT(pos < size());
+ Y_ASSERT(pos < size());
return ((T*)Ptr())[pos];
}
const T& operator[](size_t pos) const {
- Y_ASSERT(pos < size());
+ Y_ASSERT(pos < size());
return ((T*)Ptr())[pos];
}
T* begin() {
diff --git a/util/system/filemap_ut.cpp b/util/system/filemap_ut.cpp
index a0ec229681..73f109dc88 100644
--- a/util/system/filemap_ut.cpp
+++ b/util/system/filemap_ut.cpp
@@ -11,7 +11,7 @@
#include <cstring>
#include <cstdio>
-Y_UNIT_TEST_SUITE(TFileMapTest) {
+Y_UNIT_TEST_SUITE(TFileMapTest) {
static const char* FileName_("./mappped_file");
void BasicTest(TMemoryMapCommon::EOpenMode mode) {
@@ -59,7 +59,7 @@ Y_UNIT_TEST_SUITE(TFileMapTest) {
BasicTest(TMemoryMapCommon::oRdWr | TMemoryMapCommon::oPopulate);
}
- Y_UNIT_TEST(TestFileRemap) {
+ Y_UNIT_TEST(TestFileRemap) {
const char data1[] = "01234";
const char data2[] = "abcdefg";
const char data3[] = "COPY";
@@ -104,7 +104,7 @@ Y_UNIT_TEST_SUITE(TFileMapTest) {
NFs::Remove(FileName_);
}
- Y_UNIT_TEST(TestFileMapDbgName) {
+ Y_UNIT_TEST(TestFileMapDbgName) {
// This test checks that dbgName passed to the TFileMap constructor is saved inside the object and appears
// in subsequent error messages.
const char* const dbgName = "THIS_IS_A_TEST";
@@ -131,7 +131,7 @@ Y_UNIT_TEST_SUITE(TFileMapTest) {
#elif defined(_cygwin_)
//cygwin is not real unix :(
#else
- Y_UNIT_TEST(TestNotGreedy) {
+ Y_UNIT_TEST(TestNotGreedy) {
unsigned page[4096 / sizeof(unsigned)];
#if defined(_unix_)
@@ -211,7 +211,7 @@ Y_UNIT_TEST_SUITE(TFileMapTest) {
}
#endif
- Y_UNIT_TEST(TestFileMappedArray) {
+ Y_UNIT_TEST(TestFileMappedArray) {
{
TFileMappedArray<ui32> mappedArray;
ui32 data[] = {123, 456, 789, 10};
@@ -268,13 +268,13 @@ Y_UNIT_TEST_SUITE(TFileMapTest) {
NFs::Remove(FileName_);
}
- Y_UNIT_TEST(TestMappedArray) {
+ Y_UNIT_TEST(TestMappedArray) {
ui32 sz = 10;
TMappedArray<ui32> mappedArray;
ui32* ptr = mappedArray.Create(sz);
- UNIT_ASSERT(ptr != nullptr);
+ UNIT_ASSERT(ptr != nullptr);
UNIT_ASSERT(mappedArray.size() == sz);
UNIT_ASSERT(mappedArray.begin() + sz == mappedArray.end());
@@ -290,12 +290,12 @@ Y_UNIT_TEST_SUITE(TFileMapTest) {
UNIT_ASSERT(mappedArray.size() == 1000 && mappedArray2.size() == sz);
}
- Y_UNIT_TEST(TestMemoryMap) {
+ Y_UNIT_TEST(TestMemoryMap) {
TFile file(FileName_, CreateAlways | WrOnly);
file.Close();
FILE* f = fopen(FileName_, "rb");
- UNIT_ASSERT(f != nullptr);
+ UNIT_ASSERT(f != nullptr);
try {
TMemoryMap mappedMem(f);
mappedMem.Map(mappedMem.Length() / 2, mappedMem.Length() + 100); // overflow
@@ -318,7 +318,7 @@ Y_UNIT_TEST_SUITE(TFileMapTest) {
NFs::Remove(FileName_);
}
- Y_UNIT_TEST(TestMemoryMapIsWritable) {
+ Y_UNIT_TEST(TestMemoryMapIsWritable) {
TFile file(FileName_, CreateAlways | WrOnly);
file.Close();
@@ -333,7 +333,7 @@ Y_UNIT_TEST_SUITE(TFileMapTest) {
NFs::Remove(FileName_);
}
- Y_UNIT_TEST(TestFileMapIsWritable) {
+ Y_UNIT_TEST(TestFileMapIsWritable) {
TFile file(FileName_, CreateAlways | WrOnly);
file.Close();
{
diff --git a/util/system/flock_ut.cpp b/util/system/flock_ut.cpp
index 6a1caec83e..b5f6cb5328 100644
--- a/util/system/flock_ut.cpp
+++ b/util/system/flock_ut.cpp
@@ -5,15 +5,15 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TFileLockTest) {
- Y_UNIT_TEST(TestFlock) {
+Y_UNIT_TEST_SUITE(TFileLockTest) {
+ Y_UNIT_TEST(TestFlock) {
TTempFileHandle tmp("./file");
UNIT_ASSERT_EQUAL(Flock(tmp.GetHandle(), LOCK_EX), 0);
UNIT_ASSERT_EQUAL(Flock(tmp.GetHandle(), LOCK_UN), 0);
}
- Y_UNIT_TEST(TestFileLocker) {
+ Y_UNIT_TEST(TestFileLocker) {
TTempFileHandle tmp("./file.locker");
TFileLock fileLockExclusive1("./file.locker");
TFileLock fileLockExclusive2("./file.locker");
diff --git a/util/system/fs.cpp b/util/system/fs.cpp
index c95e77e4df..d2611a8ccc 100644
--- a/util/system/fs.cpp
+++ b/util/system/fs.cpp
@@ -43,7 +43,7 @@ void NFs::RemoveRecursive(const TString& path) {
switch (it->fts_info) {
case FTS_DOT:
case FTS_D:
- break;
+ break;
default:
if (!NFs::Remove(it->fts_path)) {
ythrow TSystemError() << errStr << it->fts_path << " with cwd (" << NFs::CurrentWorkingDirectory() << ")";
@@ -55,7 +55,7 @@ void NFs::RemoveRecursive(const TString& path) {
bool NFs::MakeDirectory(const TString& path, EFilePermissions mode) {
#if defined(_win_)
- Y_UNUSED(mode);
+ Y_UNUSED(mode);
return NFsPrivate::WinMakeDirectory(path);
#else
return mkdir(path.data(), mode) == 0;
@@ -65,8 +65,8 @@ bool NFs::MakeDirectory(const TString& path, EFilePermissions mode) {
bool NFs::MakeDirectoryRecursive(const TString& path, EFilePermissions mode, bool alwaysCreate) {
if (NFs::Exists(path) && TFileStat(path).IsDir()) {
if (alwaysCreate) {
- ythrow TIoException() << "path " << path << " already exists"
- << " with cwd (" << NFs::CurrentWorkingDirectory() << ")";
+ ythrow TIoException() << "path " << path << " already exists"
+ << " with cwd (" << NFs::CurrentWorkingDirectory() << ")";
}
return true;
} else {
diff --git a/util/system/fs.h b/util/system/fs.h
index 344adccc4c..237daf2d2d 100644
--- a/util/system/fs.h
+++ b/util/system/fs.h
@@ -6,18 +6,18 @@
namespace NFs {
enum EFilePermission {
- FP_ALL_EXEC = 01,
- FP_ALL_WRITE = 02,
- FP_ALL_READ = 04,
- FP_GROUP_READ = 040,
- FP_GROUP_WRITE = 020,
- FP_GROUP_EXEC = 010,
- FP_OWNER_READ = 0400,
- FP_OWNER_WRITE = 0200,
- FP_OWNER_EXEC = 0100,
-
- FP_COMMON_FILE = 0777,
- FP_SECRET_FILE = 0700,
+ FP_ALL_EXEC = 01,
+ FP_ALL_WRITE = 02,
+ FP_ALL_READ = 04,
+ FP_GROUP_READ = 040,
+ FP_GROUP_WRITE = 020,
+ FP_GROUP_EXEC = 010,
+ FP_OWNER_READ = 0400,
+ FP_OWNER_WRITE = 0200,
+ FP_OWNER_EXEC = 0100,
+
+ FP_COMMON_FILE = 0777,
+ FP_SECRET_FILE = 0700,
FP_NONSECRET_FILE = 0744,
};
@@ -148,7 +148,7 @@ namespace NFs {
/// @param[in] path Path to check
/// @returns input argument
inline const TString& EnsureExists(const TString& path) {
- Y_ENSURE_EX(Exists(path), TFileError{} << "Path " << path << " does not exists (checked from cwd:" << NFs::CurrentWorkingDirectory() << ")");
+ Y_ENSURE_EX(Exists(path), TFileError{} << "Path " << path << " does not exists (checked from cwd:" << NFs::CurrentWorkingDirectory() << ")");
return path;
}
}
diff --git a/util/system/fs_ut.cpp b/util/system/fs_ut.cpp
index 02a0c8d9ae..de071ebf55 100644
--- a/util/system/fs_ut.cpp
+++ b/util/system/fs_ut.cpp
@@ -313,8 +313,8 @@ void TFsTest::TestEnsureExists() {
TStringBuilder expected;
TString got;
try {
- NFs::EnsureExists(nonExists);
- expected << __LOCATION__;
+ NFs::EnsureExists(nonExists);
+ expected << __LOCATION__;
} catch (const TFileError& err) {
got = err.what();
}
diff --git a/util/system/fs_win.cpp b/util/system/fs_win.cpp
index 04adf6b3c1..a410ccac06 100644
--- a/util/system/fs_win.cpp
+++ b/util/system/fs_win.cpp
@@ -13,7 +13,7 @@ namespace NFsPrivate {
wstr.resize(str.size());
size_t written = 0;
if (!UTF8ToWide(str.data(), str.size(), wstr.begin(), written))
- return nullptr;
+ return nullptr;
wstr.erase(written);
static_assert(sizeof(WCHAR) == sizeof(wchar16), "expect sizeof(WCHAR) == sizeof(wchar16)");
return (const WCHAR*)wstr.data();
@@ -25,7 +25,7 @@ namespace NFsPrivate {
return WideToUTF8((wchar16*)wstr, len);
}
- HANDLE CreateFileWithUtf8Name(const TStringBuf fName, ui32 accessMode, ui32 shareMode, ui32 createMode, ui32 attributes, bool inheritHandle) {
+ HANDLE CreateFileWithUtf8Name(const TStringBuf fName, ui32 accessMode, ui32 shareMode, ui32 createMode, ui32 attributes, bool inheritHandle) {
TUtf16String wstr;
LPCWSTR wname = UTF8ToWCHAR(fName, wstr);
if (!wname) {
@@ -34,9 +34,9 @@ namespace NFsPrivate {
}
SECURITY_ATTRIBUTES secAttrs;
secAttrs.bInheritHandle = inheritHandle ? TRUE : FALSE;
- secAttrs.lpSecurityDescriptor = nullptr;
+ secAttrs.lpSecurityDescriptor = nullptr;
secAttrs.nLength = sizeof(secAttrs);
- return ::CreateFileW(wname, accessMode, shareMode, &secAttrs, createMode, attributes, nullptr);
+ return ::CreateFileW(wname, accessMode, shareMode, &secAttrs, createMode, attributes, nullptr);
}
bool WinRename(const TString& oldPath, const TString& newPath) {
@@ -110,7 +110,7 @@ namespace NFsPrivate {
return false;
}
- return (CreateHardLinkW(npPtr, epPtr, nullptr) != 0);
+ return (CreateHardLinkW(npPtr, epPtr, nullptr) != 0);
}
bool WinExists(const TString& path) {
@@ -186,7 +186,7 @@ namespace NFsPrivate {
TTempBuf buf;
while (true) {
DWORD bytesReturned = 0;
- BOOL res = DeviceIoControl(h, FSCTL_GET_REPARSE_POINT, nullptr, 0, buf.Data(), buf.Size(), &bytesReturned, nullptr);
+ BOOL res = DeviceIoControl(h, FSCTL_GET_REPARSE_POINT, nullptr, 0, buf.Data(), buf.Size(), &bytesReturned, nullptr);
if (res) {
REPARSE_DATA_BUFFER* rdb = (REPARSE_DATA_BUFFER*)buf.Data();
if (rdb->ReparseTag == IO_REPARSE_TAG_SYMLINK) {
@@ -219,8 +219,8 @@ bool GetObjectId(const char* path, GUID* id) {
if (h.IsOpen()) {
FILE_OBJECTID_BUFFER fob;
DWORD resSize = 0;
- if (DeviceIoControl(h, FSCTL_CREATE_OR_GET_OBJECT_ID, nullptr, 0, &fob, sizeof(fob), &resSize, nullptr)) {
- Y_ASSERT(resSize == sizeof(fob));
+ if (DeviceIoControl(h, FSCTL_CREATE_OR_GET_OBJECT_ID, nullptr, 0, &fob, sizeof(fob), &resSize, nullptr)) {
+ Y_ASSERT(resSize == sizeof(fob));
memcpy(id, &fob.ObjectId, sizeof(GUID));
return true;
}
diff --git a/util/system/fs_win.h b/util/system/fs_win.h
index a3deaef660..8086129828 100644
--- a/util/system/fs_win.h
+++ b/util/system/fs_win.h
@@ -15,7 +15,7 @@ namespace NFsPrivate {
TString WinReadLink(const TString& path);
- HANDLE CreateFileWithUtf8Name(const TStringBuf fName, ui32 accessMode, ui32 shareMode, ui32 createMode, ui32 attributes, bool inheritHandle);
+ HANDLE CreateFileWithUtf8Name(const TStringBuf fName, ui32 accessMode, ui32 shareMode, ui32 createMode, ui32 attributes, bool inheritHandle);
bool WinRemove(const TString& path);
diff --git a/util/system/fstat.cpp b/util/system/fstat.cpp
index d25651621a..81e98cbc6b 100644
--- a/util/system/fstat.cpp
+++ b/util/system/fstat.cpp
@@ -132,23 +132,23 @@ TFileStat::TFileStat(const char* fileName, bool nofollow) {
MakeFromFileName(fileName, nofollow);
}
-bool TFileStat::IsNull() const noexcept {
+bool TFileStat::IsNull() const noexcept {
return *this == TFileStat();
}
-bool TFileStat::IsFile() const noexcept {
+bool TFileStat::IsFile() const noexcept {
return S_ISREG(Mode);
}
-bool TFileStat::IsDir() const noexcept {
+bool TFileStat::IsDir() const noexcept {
return S_ISDIR(Mode);
}
-bool TFileStat::IsSymlink() const noexcept {
+bool TFileStat::IsSymlink() const noexcept {
return S_ISLNK(Mode);
}
-bool operator==(const TFileStat& l, const TFileStat& r) noexcept {
+bool operator==(const TFileStat& l, const TFileStat& r) noexcept {
return l.Mode == r.Mode &&
l.Uid == r.Uid &&
l.Gid == r.Gid &&
@@ -159,7 +159,7 @@ bool operator==(const TFileStat& l, const TFileStat& r) noexcept {
l.CTime == r.CTime;
}
-bool operator!=(const TFileStat& l, const TFileStat& r) noexcept {
+bool operator!=(const TFileStat& l, const TFileStat& r) noexcept {
return !(l == r);
}
diff --git a/util/system/fstat.h b/util/system/fstat.h
index 46d3db8a05..64e79e1b55 100644
--- a/util/system/fstat.h
+++ b/util/system/fstat.h
@@ -23,11 +23,11 @@ struct TFileStat {
public:
TFileStat();
- bool IsNull() const noexcept;
+ bool IsNull() const noexcept;
- bool IsFile() const noexcept;
- bool IsDir() const noexcept;
- bool IsSymlink() const noexcept;
+ bool IsFile() const noexcept;
+ bool IsDir() const noexcept;
+ bool IsSymlink() const noexcept;
explicit TFileStat(const TFile& f);
explicit TFileStat(FHANDLE f);
@@ -35,8 +35,8 @@ public:
TFileStat(const TString& fileName, bool nofollow = false);
TFileStat(const char* fileName, bool nofollow = false);
- friend bool operator==(const TFileStat& l, const TFileStat& r) noexcept;
- friend bool operator!=(const TFileStat& l, const TFileStat& r) noexcept;
+ friend bool operator==(const TFileStat& l, const TFileStat& r) noexcept;
+ friend bool operator!=(const TFileStat& l, const TFileStat& r) noexcept;
private:
void MakeFromFileName(const char* fileName, bool nofollow);
diff --git a/util/system/fstat_ut.cpp b/util/system/fstat_ut.cpp
index c7f0f27f15..160ecd936e 100644
--- a/util/system/fstat_ut.cpp
+++ b/util/system/fstat_ut.cpp
@@ -6,10 +6,10 @@
#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/testing/unittest/tests_data.h>
-#include <util/folder/path.h>
-
-Y_UNIT_TEST_SUITE(TestFileStat) {
- Y_UNIT_TEST(FileTest) {
+#include <util/folder/path.h>
+
+Y_UNIT_TEST_SUITE(TestFileStat) {
+ Y_UNIT_TEST(FileTest) {
TString fileName = "f1.txt";
TFileStat oFs;
{
@@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(TestFileStat) {
UNIT_ASSERT(unlink(fileName.data()) == 0);
}
- Y_UNIT_TEST(DirTest) {
+ Y_UNIT_TEST(DirTest) {
Mkdir("tmpd", MODE0777);
TFileStat fs("tmpd");
UNIT_ASSERT(!fs.IsFile());
@@ -62,77 +62,77 @@ Y_UNIT_TEST_SUITE(TestFileStat) {
UNIT_ASSERT(fs.CTime == 0);
}
- Y_UNIT_TEST(SymlinkToExistingFileTest) {
- const auto path = GetOutputPath() / "file_1";
- const auto link = GetOutputPath() / "symlink_1";
- TFile(path, EOpenModeFlag::CreateNew | EOpenModeFlag::RdWr);
- UNIT_ASSERT(NFs::SymLink(path, link));
-
- const TFileStat statNoFollow(link, false);
- UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsNull(), ToString(statNoFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsFile(), ToString(statNoFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode));
-
- const TFileStat statFollow(link, true);
- UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsNull(), ToString(statFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsSymlink(), ToString(statFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode));
- }
-
- Y_UNIT_TEST(SymlinkToNonExistingFileTest) {
- const auto path = GetOutputPath() / "file_2";
- const auto link = GetOutputPath() / "symlink_2";
- UNIT_ASSERT(NFs::SymLink(path, link));
-
- const TFileStat statNoFollow(link, false);
- UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsNull(), ToString(statNoFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsFile(), ToString(statNoFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode));
-
- const TFileStat statFollow(link, true);
- UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsNull(), ToString(statFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsSymlink(), ToString(statFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode));
- }
-
- Y_UNIT_TEST(SymlinkToFileThatCantExistTest) {
- const auto path = TFsPath("/path") / "that" / "does" / "not" / "exists";
- const auto link = GetOutputPath() / "symlink_3";
- UNIT_ASSERT(NFs::SymLink(path, link));
-
- const TFileStat statNoFollow(link, false);
- UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsNull(), ToString(statNoFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsFile(), ToString(statNoFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode));
-
- const TFileStat statFollow(link, true);
- UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsNull(), ToString(statFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsSymlink(), ToString(statFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode));
- }
-
- Y_UNIT_TEST(FileDoesNotExistTest) {
- const auto path = TFsPath("/path") / "that" / "does" / "not" / "exists";
-
- const TFileStat statNoFollow(path, false);
- UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsNull(), ToString(statNoFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsFile(), ToString(statNoFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode));
-
- const TFileStat statFollow(path, true);
- UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsNull(), ToString(statFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsSymlink(), ToString(statFollow.Mode));
- UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode));
- }
-
+ Y_UNIT_TEST(SymlinkToExistingFileTest) {
+ const auto path = GetOutputPath() / "file_1";
+ const auto link = GetOutputPath() / "symlink_1";
+ TFile(path, EOpenModeFlag::CreateNew | EOpenModeFlag::RdWr);
+ UNIT_ASSERT(NFs::SymLink(path, link));
+
+ const TFileStat statNoFollow(link, false);
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsNull(), ToString(statNoFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsFile(), ToString(statNoFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode));
+
+ const TFileStat statFollow(link, true);
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsNull(), ToString(statFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsSymlink(), ToString(statFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode));
+ }
+
+ Y_UNIT_TEST(SymlinkToNonExistingFileTest) {
+ const auto path = GetOutputPath() / "file_2";
+ const auto link = GetOutputPath() / "symlink_2";
+ UNIT_ASSERT(NFs::SymLink(path, link));
+
+ const TFileStat statNoFollow(link, false);
+ UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsNull(), ToString(statNoFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsFile(), ToString(statNoFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode));
+
+ const TFileStat statFollow(link, true);
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsNull(), ToString(statFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsSymlink(), ToString(statFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode));
+ }
+
+ Y_UNIT_TEST(SymlinkToFileThatCantExistTest) {
+ const auto path = TFsPath("/path") / "that" / "does" / "not" / "exists";
+ const auto link = GetOutputPath() / "symlink_3";
+ UNIT_ASSERT(NFs::SymLink(path, link));
+
+ const TFileStat statNoFollow(link, false);
+ UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsNull(), ToString(statNoFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsFile(), ToString(statNoFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode));
+
+ const TFileStat statFollow(link, true);
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsNull(), ToString(statFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsSymlink(), ToString(statFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode));
+ }
+
+ Y_UNIT_TEST(FileDoesNotExistTest) {
+ const auto path = TFsPath("/path") / "that" / "does" / "not" / "exists";
+
+ const TFileStat statNoFollow(path, false);
+ UNIT_ASSERT_VALUES_EQUAL_C(true, statNoFollow.IsNull(), ToString(statNoFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsFile(), ToString(statNoFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsSymlink(), ToString(statNoFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statNoFollow.IsDir(), ToString(statNoFollow.Mode));
+
+ const TFileStat statFollow(path, true);
+ UNIT_ASSERT_VALUES_EQUAL_C(true, statFollow.IsNull(), ToString(statFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsFile(), ToString(statFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsSymlink(), ToString(statFollow.Mode));
+ UNIT_ASSERT_VALUES_EQUAL_C(false, statFollow.IsDir(), ToString(statFollow.Mode));
+ }
+
Y_UNIT_TEST(ChmodTest) {
const TString fileName = "m.txt";
TFile file(fileName.c_str(), OpenAlways | WrOnly);
diff --git a/util/system/guard.h b/util/system/guard.h
index 49d7a4b335..efc091d5f8 100644
--- a/util/system/guard.h
+++ b/util/system/guard.h
@@ -48,7 +48,7 @@ public:
inline TGuard(TGuard&& g) noexcept
: T_(g.T_)
{
- g.T_ = nullptr;
+ g.T_ = nullptr;
}
inline ~TGuard() {
@@ -58,7 +58,7 @@ public:
inline void Release() noexcept {
if (WasAcquired()) {
TOps::Release(T_);
- T_ = nullptr;
+ T_ = nullptr;
}
}
@@ -67,7 +67,7 @@ public:
}
inline bool WasAcquired() const noexcept {
- return T_ != nullptr;
+ return T_ != nullptr;
}
inline T* GetMutex() const noexcept {
@@ -150,12 +150,12 @@ public:
inline void Release() noexcept {
if (WasAcquired()) {
TOps::Release(T_);
- T_ = nullptr;
+ T_ = nullptr;
}
}
inline bool WasAcquired() const noexcept {
- return T_ != nullptr;
+ return T_ != nullptr;
}
explicit inline operator bool() const noexcept {
@@ -164,7 +164,7 @@ public:
private:
inline void Init(const T* t) noexcept {
- T_ = nullptr;
+ T_ = nullptr;
T* tMutable = const_cast<T*>(t);
if (TOps::TryAcquire(tMutable)) {
T_ = tMutable;
diff --git a/util/system/hostname.cpp b/util/system/hostname.cpp
index 2003c6d4d3..386f646d6b 100644
--- a/util/system/hostname.cpp
+++ b/util/system/hostname.cpp
@@ -82,7 +82,7 @@ const char* GetFQDNHostName() {
bool IsFQDN(const TString& name) {
TString absName = name;
- if (!absName.EndsWith('.')) {
+ if (!absName.EndsWith('.')) {
absName.append(".");
}
diff --git a/util/system/hp_timer.cpp b/util/system/hp_timer.cpp
index 310db999e6..e4c3f21e6b 100644
--- a/util/system/hp_timer.cpp
+++ b/util/system/hp_timer.cpp
@@ -66,8 +66,8 @@ namespace {
double vec[N_VEC];
- for (auto& i : vec) {
- i = EstimateCPUClock();
+ for (auto& i : vec) {
+ i = EstimateCPUClock();
}
Sort(vec, vec + N_VEC);
@@ -93,23 +93,23 @@ namespace {
};
}
-double NHPTimer::GetSeconds(const STime& a) noexcept {
+double NHPTimer::GetSeconds(const STime& a) noexcept {
return TFreq::Instance().GetSeconds(a);
}
-double NHPTimer::GetClockRate() noexcept {
+double NHPTimer::GetClockRate() noexcept {
return TFreq::Instance().GetClockRate();
}
-ui64 NHPTimer::GetCyclesPerSecond() noexcept {
+ui64 NHPTimer::GetCyclesPerSecond() noexcept {
return TFreq::Instance().GetCyclesPerSecond();
}
-void NHPTimer::GetTime(STime* pTime) noexcept {
+void NHPTimer::GetTime(STime* pTime) noexcept {
*pTime = GetCycleCount();
}
-double NHPTimer::GetTimePassed(STime* pTime) noexcept {
+double NHPTimer::GetTimePassed(STime* pTime) noexcept {
STime old(*pTime);
*pTime = GetCycleCount();
diff --git a/util/system/hp_timer.h b/util/system/hp_timer.h
index ea02b660ed..0a4c252ec2 100644
--- a/util/system/hp_timer.h
+++ b/util/system/hp_timer.h
@@ -5,29 +5,29 @@
namespace NHPTimer {
using STime = i64;
// May delay for ~50ms to compute frequency
- double GetSeconds(const STime& a) noexcept;
+ double GetSeconds(const STime& a) noexcept;
// Returns the current time
- void GetTime(STime* pTime) noexcept;
+ void GetTime(STime* pTime) noexcept;
// Returns the time passed since *pTime, and writes the current time into *pTime.
- double GetTimePassed(STime* pTime) noexcept;
+ double GetTimePassed(STime* pTime) noexcept;
// Get TSC frequency, may delay for ~50ms to compute frequency
- double GetClockRate() noexcept;
- // same as GetClockRate, but in integer
- ui64 GetCyclesPerSecond() noexcept;
+ double GetClockRate() noexcept;
+ // same as GetClockRate, but in integer
+ ui64 GetCyclesPerSecond() noexcept;
}
struct THPTimer {
THPTimer() noexcept {
Reset();
}
- void Reset() noexcept {
+ void Reset() noexcept {
NHPTimer::GetTime(&Start);
}
- double Passed() const noexcept {
+ double Passed() const noexcept {
NHPTimer::STime tmp = Start;
return NHPTimer::GetTimePassed(&tmp);
}
- double PassedReset() noexcept {
+ double PassedReset() noexcept {
return NHPTimer::GetTimePassed(&Start);
}
diff --git a/util/system/info.cpp b/util/system/info.cpp
index 78db83cd61..cf6681e89a 100644
--- a/util/system/info.cpp
+++ b/util/system/info.cpp
@@ -134,7 +134,7 @@ size_t NSystemInfo::NumberOfCpus() {
mib[0] = CTL_HW;
mib[1] = HW_NCPU;
len = sizeof(ncpus);
- if (sysctl(mib, 2, &ncpus, &len, nullptr, 0) == -1) {
+ if (sysctl(mib, 2, &ncpus, &len, nullptr, 0) == -1) {
abort();
}
diff --git a/util/system/mem_info.cpp b/util/system/mem_info.cpp
index e5f60b49be..aa51ae3b16 100644
--- a/util/system/mem_info.cpp
+++ b/util/system/mem_info.cpp
@@ -134,7 +134,7 @@ namespace NMemInfo {
Zero(proc);
errno = 0;
- if (sysctl((int*)mib, 4, &proc, &size, nullptr, 0) == -1) {
+ if (sysctl((int*)mib, 4, &proc, &size, nullptr, 0) == -1) {
int err = errno;
TString errtxt = LastSystemErrorText(err);
ythrow yexception() << "sysctl({CTL_KERN,KERN_PROC,KERN_PROC_PID,pid},4,proc,&size,NULL,0) returned -1, errno: " << err << " (" << errtxt << ")" << Endl;
diff --git a/util/system/mutex.cpp b/util/system/mutex.cpp
index b4513615a2..4041402db9 100644
--- a/util/system/mutex.cpp
+++ b/util/system/mutex.cpp
@@ -35,7 +35,7 @@ public:
inline ~T() {
int result = pthread_mutexattr_destroy(&Attr);
- Y_VERIFY(result == 0, "mutexattr destroy(%s)", LastSystemErrorText(result));
+ Y_VERIFY(result == 0, "mutexattr destroy(%s)", LastSystemErrorText(result));
}
} pma;
@@ -51,7 +51,7 @@ public:
DeleteCriticalSection(&Obj);
#else
int result = pthread_mutex_destroy(&Obj);
- Y_VERIFY(result == 0, "mutex destroy failure (%s)", LastSystemErrorText(result));
+ Y_VERIFY(result == 0, "mutex destroy failure (%s)", LastSystemErrorText(result));
#endif
}
@@ -60,7 +60,7 @@ public:
EnterCriticalSection(&Obj);
#else
int result = pthread_mutex_lock(&Obj);
- Y_VERIFY(result == 0, "mutex lock failure (%s)", LastSystemErrorText(result));
+ Y_VERIFY(result == 0, "mutex lock failure (%s)", LastSystemErrorText(result));
#endif
}
@@ -95,7 +95,7 @@ public:
if (result == 0 || result == EBUSY) {
return result == 0;
}
- Y_FAIL("mutex trylock failure (%s)", LastSystemErrorText(result));
+ Y_FAIL("mutex trylock failure (%s)", LastSystemErrorText(result));
#endif
}
@@ -104,7 +104,7 @@ public:
LeaveCriticalSection(&Obj);
#else
int result = pthread_mutex_unlock(&Obj);
- Y_VERIFY(result == 0, "mutex unlock failure (%s)", LastSystemErrorText(result));
+ Y_VERIFY(result == 0, "mutex unlock failure (%s)", LastSystemErrorText(result));
#endif
}
diff --git a/util/system/nice_ut.cpp b/util/system/nice_ut.cpp
index bc8d942da8..ae0051f285 100644
--- a/util/system/nice_ut.cpp
+++ b/util/system/nice_ut.cpp
@@ -12,13 +12,13 @@ static int GetPriority() {
}
#endif
-Y_UNIT_TEST_SUITE(NiceTest) {
- Y_UNIT_TEST(TestNiceZero) {
+Y_UNIT_TEST_SUITE(NiceTest) {
+ Y_UNIT_TEST(TestNiceZero) {
UNIT_ASSERT(Nice(0));
UNIT_ASSERT(Nice(0));
}
#ifdef _unix_
- Y_UNIT_TEST(TestNice) {
+ Y_UNIT_TEST(TestNice) {
int prio = GetPriority();
if (prio >= 10) {
diff --git a/util/system/pipe.cpp b/util/system/pipe.cpp
index 6bb915513b..a543bd7472 100644
--- a/util/system/pipe.cpp
+++ b/util/system/pipe.cpp
@@ -1,6 +1,6 @@
#include "pipe.h"
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/generic/yexception.h>
ssize_t TPipeHandle::Read(void* buffer, size_t byteCount) const noexcept {
diff --git a/util/system/pipe_ut.cpp b/util/system/pipe_ut.cpp
index d120804e4b..6d53432de8 100644
--- a/util/system/pipe_ut.cpp
+++ b/util/system/pipe_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TPipeTest) {
- Y_UNIT_TEST(TestPipe) {
+Y_UNIT_TEST_SUITE(TPipeTest) {
+ Y_UNIT_TEST(TestPipe) {
TPipe r;
TPipe w;
TPipe::Pipe(r, w);
diff --git a/util/system/progname.cpp b/util/system/progname.cpp
index 9ed924ad4c..2c29119320 100644
--- a/util/system/progname.cpp
+++ b/util/system/progname.cpp
@@ -18,7 +18,7 @@ namespace {
}
const TString& GetProgramName() {
- return Singleton<TProgramNameHolder>()->ProgName;
+ return Singleton<TProgramNameHolder>()->ProgName;
}
void SetProgramName(const char* argv0) {
diff --git a/util/system/progname_ut.cpp b/util/system/progname_ut.cpp
index 6c2709e26e..11f3d9308b 100644
--- a/util/system/progname_ut.cpp
+++ b/util/system/progname_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TProgramNameTest) {
- Y_UNIT_TEST(TestIt) {
+Y_UNIT_TEST_SUITE(TProgramNameTest) {
+ Y_UNIT_TEST(TestIt) {
TString progName = GetProgramName();
try {
diff --git a/util/system/rusage_ut.cpp b/util/system/rusage_ut.cpp
index dcb771be71..0d4e0fe54b 100644
--- a/util/system/rusage_ut.cpp
+++ b/util/system/rusage_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TRusageTest) {
- Y_UNIT_TEST(TestRusage) {
+Y_UNIT_TEST_SUITE(TRusageTest) {
+ Y_UNIT_TEST(TestRusage) {
TRusage r;
// just check it returns something
r.Fill();
diff --git a/util/system/rwlock.cpp b/util/system/rwlock.cpp
index 067cbd5140..bb3dcbf188 100644
--- a/util/system/rwlock.cpp
+++ b/util/system/rwlock.cpp
@@ -164,7 +164,7 @@ private:
};
TRWMutex::TImpl::TImpl() {
- int result = pthread_rwlock_init(&Lock_, nullptr);
+ int result = pthread_rwlock_init(&Lock_, nullptr);
if (result != 0) {
ythrow yexception() << "rwlock init failed (" << LastSystemErrorText(result) << ")";
}
@@ -172,44 +172,44 @@ TRWMutex::TImpl::TImpl() {
TRWMutex::TImpl::~TImpl() {
const int result = pthread_rwlock_destroy(&Lock_);
- Y_VERIFY(result == 0, "rwlock destroy failed (%s)", LastSystemErrorText(result));
+ Y_VERIFY(result == 0, "rwlock destroy failed (%s)", LastSystemErrorText(result));
}
void TRWMutex::TImpl::AcquireRead() noexcept {
const int result = pthread_rwlock_rdlock(&Lock_);
- Y_VERIFY(result == 0, "rwlock rdlock failed (%s)", LastSystemErrorText(result));
+ Y_VERIFY(result == 0, "rwlock rdlock failed (%s)", LastSystemErrorText(result));
}
bool TRWMutex::TImpl::TryAcquireRead() noexcept {
const int result = pthread_rwlock_tryrdlock(&Lock_);
- Y_VERIFY(result == 0 || result == EBUSY, "rwlock tryrdlock failed (%s)", LastSystemErrorText(result));
+ Y_VERIFY(result == 0 || result == EBUSY, "rwlock tryrdlock failed (%s)", LastSystemErrorText(result));
return result == 0;
}
void TRWMutex::TImpl::ReleaseRead() noexcept {
const int result = pthread_rwlock_unlock(&Lock_);
- Y_VERIFY(result == 0, "rwlock (read) unlock failed (%s)", LastSystemErrorText(result));
+ Y_VERIFY(result == 0, "rwlock (read) unlock failed (%s)", LastSystemErrorText(result));
}
void TRWMutex::TImpl::AcquireWrite() noexcept {
const int result = pthread_rwlock_wrlock(&Lock_);
- Y_VERIFY(result == 0, "rwlock wrlock failed (%s)", LastSystemErrorText(result));
+ Y_VERIFY(result == 0, "rwlock wrlock failed (%s)", LastSystemErrorText(result));
}
bool TRWMutex::TImpl::TryAcquireWrite() noexcept {
const int result = pthread_rwlock_trywrlock(&Lock_);
- Y_VERIFY(result == 0 || result == EBUSY, "rwlock trywrlock failed (%s)", LastSystemErrorText(result));
+ Y_VERIFY(result == 0 || result == EBUSY, "rwlock trywrlock failed (%s)", LastSystemErrorText(result));
return result == 0;
}
void TRWMutex::TImpl::ReleaseWrite() noexcept {
const int result = pthread_rwlock_unlock(&Lock_);
- Y_VERIFY(result == 0, "rwlock (write) unlock failed (%s)", LastSystemErrorText(result));
+ Y_VERIFY(result == 0, "rwlock (write) unlock failed (%s)", LastSystemErrorText(result));
}
void TRWMutex::TImpl::Release() noexcept {
const int result = pthread_rwlock_unlock(&Lock_);
- Y_VERIFY(result == 0, "rwlock unlock failed (%s)", LastSystemErrorText(result));
+ Y_VERIFY(result == 0, "rwlock unlock failed (%s)", LastSystemErrorText(result));
}
#endif
diff --git a/util/system/sanitizers_ut.cpp b/util/system/sanitizers_ut.cpp
index 99480202a6..5de096e14b 100644
--- a/util/system/sanitizers_ut.cpp
+++ b/util/system/sanitizers_ut.cpp
@@ -3,8 +3,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(Sanitizers) {
- Y_UNIT_TEST(MarkAsIntentionallyLeaked) {
+Y_UNIT_TEST_SUITE(Sanitizers) {
+ Y_UNIT_TEST(MarkAsIntentionallyLeaked) {
auto* p1 = new i32[100];
NSan::MarkAsIntentionallyLeaked(p1);
@@ -12,4 +12,4 @@ Y_UNIT_TEST_SUITE(Sanitizers) {
NSan::MarkAsIntentionallyLeaked(p2);
}
-} // Y_UNIT_TEST_SUITE(Sanitizers)
+} // Y_UNIT_TEST_SUITE(Sanitizers)
diff --git a/util/system/sem.cpp b/util/system/sem.cpp
index 8263992de4..4a93b903b5 100644
--- a/util/system/sem.cpp
+++ b/util/system/sem.cpp
@@ -129,7 +129,7 @@ namespace {
#else
int ret = sem_post(Handle);
#endif
- Y_VERIFY(ret == 0, "can not release semaphore");
+ Y_VERIFY(ret == 0, "can not release semaphore");
#endif
}
@@ -137,7 +137,7 @@ namespace {
//hence to maintain consistancy, for win32 case we use INFINITE or 0 timeout.
inline void Acquire() noexcept {
#ifdef _win_
- Y_VERIFY(::WaitForSingleObject(Handle, INFINITE) == WAIT_OBJECT_0, "can not acquire semaphore");
+ Y_VERIFY(::WaitForSingleObject(Handle, INFINITE) == WAIT_OBJECT_0, "can not acquire semaphore");
#else
#ifdef USE_SYSV_SEMAPHORES
struct sembuf ops[] = {{0, -1, SEM_UNDO}};
@@ -145,7 +145,7 @@ namespace {
#else
int ret = sem_wait(Handle);
#endif
- Y_VERIFY(ret == 0, "can not acquire semaphore");
+ Y_VERIFY(ret == 0, "can not acquire semaphore");
#endif
}
@@ -183,20 +183,20 @@ namespace {
}
inline ~TPosixSemaphore() {
- Y_VERIFY(sem_destroy(&S_) == 0, "semaphore destroy failed");
+ Y_VERIFY(sem_destroy(&S_) == 0, "semaphore destroy failed");
}
inline void Acquire() noexcept {
- Y_VERIFY(sem_wait(&S_) == 0, "semaphore acquire failed");
+ Y_VERIFY(sem_wait(&S_) == 0, "semaphore acquire failed");
}
inline void Release() noexcept {
- Y_VERIFY(sem_post(&S_) == 0, "semaphore release failed");
+ Y_VERIFY(sem_post(&S_) == 0, "semaphore release failed");
}
inline bool TryAcquire() noexcept {
if (sem_trywait(&S_)) {
- Y_VERIFY(errno == EAGAIN, "semaphore try wait failed");
+ Y_VERIFY(errno == EAGAIN, "semaphore try wait failed");
return false;
}
diff --git a/util/system/shellcommand.cpp b/util/system/shellcommand.cpp
index 7ba438be12..b1989b5c8c 100644
--- a/util/system/shellcommand.cpp
+++ b/util/system/shellcommand.cpp
@@ -2,16 +2,16 @@
#include "user.h"
#include "nice.h"
#include "sigset.h"
-#include "atomic.h"
-
+#include "atomic.h"
+
#include <util/folder/dirut.h>
-#include <util/generic/algorithm.h>
-#include <util/generic/buffer.h>
-#include <util/generic/vector.h>
-#include <util/generic/yexception.h>
-#include <util/memory/tempbuf.h>
+#include <util/generic/algorithm.h>
+#include <util/generic/buffer.h>
+#include <util/generic/vector.h>
+#include <util/generic/yexception.h>
+#include <util/memory/tempbuf.h>
#include <util/network/socket.h>
-#include <util/stream/pipe.h>
+#include <util/stream/pipe.h>
#include <util/stream/str.h>
#include <util/string/cast.h>
#include <util/system/info.h>
@@ -157,13 +157,13 @@ public:
ssize_t Read(void* buffer, size_t byteCount) const noexcept {
DWORD doneBytes;
- if (!ReadFile(Fd_, buffer, byteCount, &doneBytes, nullptr))
+ if (!ReadFile(Fd_, buffer, byteCount, &doneBytes, nullptr))
return -1;
return doneBytes;
}
ssize_t Write(const void* buffer, size_t byteCount) const noexcept {
DWORD doneBytes;
- if (!WriteFile(Fd_, buffer, byteCount, &doneBytes, nullptr))
+ if (!WriteFile(Fd_, buffer, byteCount, &doneBytes, nullptr))
return -1;
return doneBytes;
}
@@ -196,9 +196,9 @@ private:
TString WorkDir;
TAtomic ExecutionStatus; // TShellCommand::ECommandStatus
TMaybe<int> ExitCode;
- IInputStream* InputStream;
- IOutputStream* OutputStream;
- IOutputStream* ErrorStream;
+ IInputStream* InputStream;
+ IOutputStream* OutputStream;
+ IOutputStream* ErrorStream;
TString CollectedOutput;
TString CollectedError;
TString InternalError;
@@ -289,7 +289,7 @@ public:
, InputStream(options.InputStream)
, OutputStream(options.OutputStream)
, ErrorStream(options.ErrorStream)
- , WatchThread(nullptr)
+ , WatchThread(nullptr)
, TerminateFlag(false)
, ClearSignalMask(options.ClearSignalMask)
, CloseAllFdsOnExec(options.CloseAllFdsOnExec)
@@ -330,36 +330,36 @@ public:
#endif
}
- inline void AppendArgument(const TStringBuf argument) {
- if (AtomicGet(ExecutionStatus) == SHELL_RUNNING) {
+ inline void AppendArgument(const TStringBuf argument) {
+ if (AtomicGet(ExecutionStatus) == SHELL_RUNNING) {
ythrow yexception() << "You cannot change command parameters while process is running";
}
Arguments.push_back(ToString(argument));
}
inline const TString& GetOutput() const {
- if (AtomicGet(ExecutionStatus) == SHELL_RUNNING) {
+ if (AtomicGet(ExecutionStatus) == SHELL_RUNNING) {
ythrow yexception() << "You cannot retrieve output while process is running.";
}
return CollectedOutput;
}
inline const TString& GetError() const {
- if (AtomicGet(ExecutionStatus) == SHELL_RUNNING) {
+ if (AtomicGet(ExecutionStatus) == SHELL_RUNNING) {
ythrow yexception() << "You cannot retrieve output while process is running.";
}
return CollectedError;
}
inline const TString& GetInternalError() const {
- if (AtomicGet(ExecutionStatus) != SHELL_INTERNAL_ERROR) {
+ if (AtomicGet(ExecutionStatus) != SHELL_INTERNAL_ERROR) {
ythrow yexception() << "Internal error hasn't occured so can't be retrieved.";
}
return InternalError;
}
inline ECommandStatus GetStatus() const {
- return static_cast<ECommandStatus>(AtomicGet(ExecutionStatus));
+ return static_cast<ECommandStatus>(AtomicGet(ExecutionStatus));
}
inline TMaybe<int> GetExitCode() const {
@@ -390,7 +390,7 @@ public:
void Run();
inline void Terminate() {
- if (!!Pid && (AtomicGet(ExecutionStatus) == SHELL_RUNNING)) {
+ if (!!Pid && (AtomicGet(ExecutionStatus) == SHELL_RUNNING)) {
bool ok =
#if defined(_unix_)
kill(DetachSession ? -1 * Pid : Pid, SIGTERM) == 0;
@@ -446,7 +446,7 @@ public:
inline static void* WatchProcess(void* data) {
TProcessInfo* pi = reinterpret_cast<TProcessInfo*>(data);
Communicate(pi);
- return nullptr;
+ return nullptr;
}
inline static void* ReadStream(void* data) noexcept {
@@ -573,7 +573,7 @@ void TShellCommand::TImpl::StartProcess(TShellCommand::TImpl::TPipes& pipes) {
cwd = cwdBuff.c_str();
}
- void* lpEnvironment = nullptr;
+ void* lpEnvironment = nullptr;
TString env;
if (!Environment.empty()) {
for (auto e = Environment.begin(); e != Environment.end(); ++e) {
@@ -590,7 +590,7 @@ void TShellCommand::TImpl::StartProcess(TShellCommand::TImpl::TPipes& pipes) {
BOOL res = 0;
if (User.Name.empty() || GetUsername() == User.Name) {
res = CreateProcessW(
- nullptr, // image name
+ nullptr, // image name
cmdcopy.Data(),
nullptr, // process security attributes
nullptr, // thread security attributes
@@ -603,7 +603,7 @@ void TShellCommand::TImpl::StartProcess(TShellCommand::TImpl::TPipes& pipes) {
} else {
res = CreateProcessWithLogonW(
GetWString(User.Name.data()).c_str(),
- nullptr, // domain (if this parameter is NULL, the user name must be specified in UPN format)
+ nullptr, // domain (if this parameter is NULL, the user name must be specified in UPN format)
GetWString(User.Password.data()).c_str(),
0, // logon flags
NULL, // image name
@@ -616,7 +616,7 @@ void TShellCommand::TImpl::StartProcess(TShellCommand::TImpl::TPipes& pipes) {
}
if (!res) {
- AtomicSet(ExecutionStatus, SHELL_ERROR);
+ AtomicSet(ExecutionStatus, SHELL_ERROR);
/// @todo: write to error stream if set
TStringOutput out(CollectedError);
out << "Process was not created: " << LastSystemErrorText() << " command text was: '" << GetAString(cmdcopy.Data()) << "'";
@@ -653,12 +653,12 @@ bool ArgNeedsQuotes(TStringBuf arg) noexcept {
TString TShellCommand::TImpl::GetQuotedCommand() const {
TString quoted = Command; /// @todo command itself should be quoted too
- for (const auto& argument : Arguments) {
+ for (const auto& argument : Arguments) {
// Don't add unnecessary quotes. It's especially important for the windows with a 32k command line length limit.
if (QuoteArguments && ArgNeedsQuotes(argument)) {
- ::ShellQuoteArgSp(quoted, argument);
+ ::ShellQuoteArgSp(quoted, argument);
} else {
- quoted.append(" ").append(argument);
+ quoted.append(" ").append(argument);
}
}
return quoted;
@@ -678,13 +678,13 @@ void TShellCommand::TImpl::OnFork(TPipes& pipes, sigset_t oldmask, char* const*
SigEmptySet(&sa.sa_mask);
for (int i = 0; i < NSIG; ++i) {
// some signals cannot be caught, so just ignore return value
- sigaction(i, &sa, nullptr);
+ sigaction(i, &sa, nullptr);
}
if (ClearSignalMask) {
SigEmptySet(&oldmask);
}
// clear / restore signal mask
- if (SigProcMask(SIG_SETMASK, &oldmask, nullptr) != 0) {
+ if (SigProcMask(SIG_SETMASK, &oldmask, nullptr) != 0) {
ythrow TSystemError() << "Cannot " << (ClearSignalMask ? "clear" : "restore") << " signal mask in child";
}
@@ -772,7 +772,7 @@ void TShellCommand::TImpl::Run() {
TRealPipeHandle::Pipe(pipes.InputPipeFd[0], pipes.InputPipeFd[1], CloseOnExec);
}
- AtomicSet(ExecutionStatus, SHELL_RUNNING);
+ AtomicSet(ExecutionStatus, SHELL_RUNNING);
#if defined(_unix_)
// block all signals to avoid signal handler race after fork()
@@ -819,7 +819,7 @@ void TShellCommand::TImpl::Run() {
pid_t pid = fork();
if (pid == -1) {
- AtomicSet(ExecutionStatus, SHELL_ERROR);
+ AtomicSet(ExecutionStatus, SHELL_ERROR);
/// @todo check if pipes are still open
ythrow TSystemError() << "Cannot fork";
} else if (pid == 0) { // child
@@ -830,7 +830,7 @@ void TShellCommand::TImpl::Run() {
}
} else { // parent
// restore signal mask
- if (SigProcMask(SIG_SETMASK, &oldmask, nullptr) != 0) {
+ if (SigProcMask(SIG_SETMASK, &oldmask, nullptr) != 0) {
ythrow TSystemError() << "Cannot restore signal mask in parent";
}
}
@@ -873,19 +873,19 @@ void TShellCommand::TImpl::Run() {
}
void TShellCommand::TImpl::Communicate(TProcessInfo* pi) {
- THolder<IOutputStream> outputHolder;
- IOutputStream* output = pi->Parent->OutputStream;
+ THolder<IOutputStream> outputHolder;
+ IOutputStream* output = pi->Parent->OutputStream;
if (!output) {
outputHolder.Reset(output = new TStringOutput(pi->Parent->CollectedOutput));
}
- THolder<IOutputStream> errorHolder;
- IOutputStream* error = pi->Parent->ErrorStream;
+ THolder<IOutputStream> errorHolder;
+ IOutputStream* error = pi->Parent->ErrorStream;
if (!error) {
errorHolder.Reset(error = new TStringOutput(pi->Parent->CollectedError));
}
- IInputStream*& input = pi->Parent->InputStream;
+ IInputStream*& input = pi->Parent->InputStream;
#if defined(_unix_)
// not really needed, io is done via poll
@@ -922,7 +922,7 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) {
TBuffer inputBuffer(DATA_BUFFER_SIZE);
int bytes;
int bytesToWrite = 0;
- char* bufPos = nullptr;
+ char* bufPos = nullptr;
#endif
TWaitResult waitPidResult;
TExitStatus status = 0;
@@ -940,7 +940,7 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) {
waitpid(pi->Parent->Pid, &status, WNOHANG);
#else
WaitForSingleObject(pi->Parent->Pid /* process_info.hProcess */, pi->Parent->PollDelayMs /* ms */);
- Y_UNUSED(status);
+ Y_UNUSED(status);
#endif
// DBG(Cerr << "wait result: " << waitPidResult << Endl);
if (waitPidResult != WAIT_PROCEED) {
@@ -999,13 +999,13 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) {
if ((fds[1].revents & POLLIN) == POLLIN) {
haveOut = true;
} else if (fds[1].revents & (POLLERR | POLLHUP)) {
- output = nullptr;
+ output = nullptr;
}
if ((fds[2].revents & POLLIN) == POLLIN) {
haveErr = true;
} else if (fds[2].revents & (POLLERR | POLLHUP)) {
- error = nullptr;
+ error = nullptr;
}
if (input && ((fds[0].revents & POLLOUT) == POLLOUT)) {
@@ -1018,7 +1018,7 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) {
if (bytes > 0) {
output->Write(buffer.Data(), bytes);
} else {
- output = nullptr;
+ output = nullptr;
}
}
if (haveErr) {
@@ -1027,7 +1027,7 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) {
if (bytes > 0) {
error->Write(buffer.Data(), bytes);
} else {
- error = nullptr;
+ error = nullptr;
}
}
@@ -1048,7 +1048,7 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) {
bytesToWrite -= bytes;
bufPos += bytes;
} else {
- input = nullptr;
+ input = nullptr;
}
DBG(Cerr << "transferred " << bytes << " bytes of input" << Endl);
@@ -1084,9 +1084,9 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) {
#endif
pi->Parent->ExitCode = processExitCode;
if (cleanExit) {
- AtomicSet(pi->Parent->ExecutionStatus, SHELL_FINISHED);
+ AtomicSet(pi->Parent->ExecutionStatus, SHELL_FINISHED);
} else {
- AtomicSet(pi->Parent->ExecutionStatus, SHELL_ERROR);
+ AtomicSet(pi->Parent->ExecutionStatus, SHELL_ERROR);
}
#if defined(_win_)
@@ -1109,7 +1109,7 @@ void TShellCommand::TImpl::Communicate(TProcessInfo* pi) {
#endif
} catch (const yexception& e) {
// Some error in watch occured, set result to error
- AtomicSet(pi->Parent->ExecutionStatus, SHELL_INTERNAL_ERROR);
+ AtomicSet(pi->Parent->ExecutionStatus, SHELL_INTERNAL_ERROR);
pi->Parent->InternalError = e.what();
if (input) {
pi->InputFd.Close();
@@ -1134,7 +1134,7 @@ TShellCommand::TShellCommand(const TStringBuf cmd, const TShellCommandOptions& o
TShellCommand::~TShellCommand() = default;
-TShellCommand& TShellCommand::operator<<(const TStringBuf argument) {
+TShellCommand& TShellCommand::operator<<(const TStringBuf argument) {
Impl->AppendArgument(argument);
return *this;
}
diff --git a/util/system/shellcommand.h b/util/system/shellcommand.h
index 6141b8ae0e..8730627fe5 100644
--- a/util/system/shellcommand.h
+++ b/util/system/shellcommand.h
@@ -129,7 +129,7 @@ public:
*
* @return self
*/
- inline TShellCommandOptions& SetInputStream(IInputStream* stream) {
+ inline TShellCommandOptions& SetInputStream(IInputStream* stream) {
InputStream = stream;
if (InputStream == nullptr) {
InputMode = HANDLE_INHERIT;
@@ -148,7 +148,7 @@ public:
*
* @return self
*/
- inline TShellCommandOptions& SetOutputStream(IOutputStream* stream) {
+ inline TShellCommandOptions& SetOutputStream(IOutputStream* stream) {
OutputStream = stream;
return *this;
}
@@ -162,7 +162,7 @@ public:
*
* @return self
*/
- inline TShellCommandOptions& SetErrorStream(IOutputStream* stream) {
+ inline TShellCommandOptions& SetErrorStream(IOutputStream* stream) {
ErrorStream = stream;
return *this;
}
@@ -313,10 +313,10 @@ public:
// bool SearchPath // search exe name in $PATH
// bool UnicodeConsole
// bool EmulateConsole // provide isatty == true
- /// @todo command's stdin should be exposet as IOutputStream to support dialogue
- IInputStream* InputStream;
- IOutputStream* OutputStream;
- IOutputStream* ErrorStream;
+ /// @todo command's stdin should be exposet as IOutputStream to support dialogue
+ IInputStream* InputStream;
+ IOutputStream* OutputStream;
+ IOutputStream* ErrorStream;
TUserOptions User;
THashMap<TString, TString> Environment;
int Nice = 0;
@@ -364,7 +364,7 @@ public:
*
* @return self
*/
- TShellCommand& operator<<(const TStringBuf argument);
+ TShellCommand& operator<<(const TStringBuf argument);
/**
* @brief return the collected output from the command.
diff --git a/util/system/shellcommand_ut.cpp b/util/system/shellcommand_ut.cpp
index 5546c41dd3..9d849279d2 100644
--- a/util/system/shellcommand_ut.cpp
+++ b/util/system/shellcommand_ut.cpp
@@ -27,7 +27,7 @@ const char catCommand[] = "/bin/cat";
const size_t textSize = 20000;
#endif
-class TGuardedStringStream: public IInputStream, public IOutputStream {
+class TGuardedStringStream: public IInputStream, public IOutputStream {
public:
TGuardedStringStream() {
Stream_.Reserve(100);
@@ -59,8 +59,8 @@ private:
TStringStream Stream_;
};
-Y_UNIT_TEST_SUITE(TShellQuoteTest) {
- Y_UNIT_TEST(TestQuoteArg) {
+Y_UNIT_TEST_SUITE(TShellQuoteTest) {
+ Y_UNIT_TEST(TestQuoteArg) {
TString cmd;
ShellQuoteArg(cmd, "/pr f/krev/prev.exe");
ShellQuoteArgSp(cmd, "-DVal=\"W Quotes\"");
@@ -70,8 +70,8 @@ Y_UNIT_TEST_SUITE(TShellQuoteTest) {
}
}
-Y_UNIT_TEST_SUITE(TShellCommandTest) {
- Y_UNIT_TEST(TestNoQuotes) {
+Y_UNIT_TEST_SUITE(TShellCommandTest) {
+ Y_UNIT_TEST(TestNoQuotes) {
TShellCommandOptions options;
options.SetQuoteArguments(false);
TShellCommand cmd("echo hello");
@@ -97,7 +97,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
UNIT_ASSERT(cmd.GetExitCode().Defined() && 0 == cmd.GetExitCode());
}
- Y_UNIT_TEST(TestRun) {
+ Y_UNIT_TEST(TestRun) {
TShellCommand cmd("echo");
cmd << "hello";
cmd.Run();
@@ -112,7 +112,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
}
// running with no shell is not implemented for win
// there should be no problem with it as long as SearchPath is on
- Y_UNIT_TEST(TestNoShell) {
+ Y_UNIT_TEST(TestNoShell) {
#if defined(_win_)
const char dir[] = "dir";
#else
@@ -143,7 +143,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
UNIT_ASSERT(cmd.GetExitCode().Defined() && 0 == cmd.GetExitCode());
}
}
- Y_UNIT_TEST(TestAsyncRun) {
+ Y_UNIT_TEST(TestAsyncRun) {
TShellCommandOptions options;
options.SetAsync(true);
#if defined(_win_)
@@ -168,7 +168,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
UNIT_ASSERT(cmd.GetExitCode().Defined() && 0 == cmd.GetExitCode());
#endif
}
- Y_UNIT_TEST(TestQuotes) {
+ Y_UNIT_TEST(TestQuotes) {
TShellCommandOptions options;
TString input = TString("a\"a a");
TString output;
@@ -185,14 +185,14 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
#endif
UNIT_ASSERT_VALUES_EQUAL(cmd.GetError().size(), 0u);
}
- Y_UNIT_TEST(TestRunNonexistent) {
+ Y_UNIT_TEST(TestRunNonexistent) {
TShellCommand cmd("iwerognweiofnewio"); // some nonexistent command name
cmd.Run().Wait();
UNIT_ASSERT(TShellCommand::SHELL_ERROR == cmd.GetStatus());
UNIT_ASSERT_VALUES_UNEQUAL(cmd.GetError().size(), 0u);
UNIT_ASSERT(cmd.GetExitCode().Defined() && 0 != cmd.GetExitCode());
}
- Y_UNIT_TEST(TestExitCode) {
+ Y_UNIT_TEST(TestExitCode) {
TShellCommand cmd("grep qwerty qwerty"); // some nonexistent file name
cmd.Run().Wait();
UNIT_ASSERT(TShellCommand::SHELL_ERROR == cmd.GetStatus());
@@ -200,7 +200,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
UNIT_ASSERT(cmd.GetExitCode().Defined() && 2 == cmd.GetExitCode());
}
// 'type con' and 'copy con con' want real console, not stdin, use sort
- Y_UNIT_TEST(TestInput) {
+ Y_UNIT_TEST(TestInput) {
TShellCommandOptions options;
TString input = (TString("a") * 2000).append(NL) * textSize;
TStringInput inputStream(input);
@@ -210,7 +210,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
UNIT_ASSERT_VALUES_EQUAL(input, cmd.GetOutput());
UNIT_ASSERT_VALUES_EQUAL(cmd.GetError().size(), 0u);
}
- Y_UNIT_TEST(TestOutput) {
+ Y_UNIT_TEST(TestOutput) {
TShellCommandOptions options;
TString input = (TString("a") * 2000).append(NL) * textSize;
TStringInput inputStream(input);
@@ -223,7 +223,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
UNIT_ASSERT_VALUES_EQUAL(input, output);
UNIT_ASSERT_VALUES_EQUAL(cmd.GetError().size(), 0u);
}
- Y_UNIT_TEST(TestIO) {
+ Y_UNIT_TEST(TestIO) {
// descriptive test: use all options
TShellCommandOptions options;
options.SetAsync(true);
@@ -260,12 +260,12 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
UNIT_ASSERT_VALUES_EQUAL(read.Str(), "alpha" NL "omega" NL "zeta" NL);
UNIT_ASSERT(cmd.GetExitCode().Defined() && 0 == cmd.GetExitCode());
}
- Y_UNIT_TEST(TestStreamClose) {
- struct TStream: public IOutputStream {
+ Y_UNIT_TEST(TestStreamClose) {
+ struct TStream: public IOutputStream {
size_t NumCloses = 0;
void DoWrite(const void* buf, size_t len) override {
- Y_UNUSED(buf);
- Y_UNUSED(len);
+ Y_UNUSED(buf);
+ Y_UNUSED(len);
}
void DoFinish() override {
++NumCloses;
@@ -280,7 +280,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
TShellCommand("echo hello", options).Run().Wait();
UNIT_ASSERT_VALUES_EQUAL(stream.NumCloses, 2);
}
- Y_UNIT_TEST(TestInterruptSimple) {
+ Y_UNIT_TEST(TestInterruptSimple) {
TShellCommandOptions options;
options.SetAsync(true);
options.SetCloseInput(false);
@@ -296,7 +296,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
}
#if !defined(_win_)
// this ut is unix-only, port to win using %TEMP%
- Y_UNIT_TEST(TestInterrupt) {
+ Y_UNIT_TEST(TestInterrupt) {
TString tmpfile = TString("shellcommand_ut.interrupt.") + ToString(RandomNumber<ui32>());
TShellCommandOptions options;
@@ -318,7 +318,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
UNIT_ASSERT(!NFs::Exists(tmpfile));
}
// this ut is unix-only (win has no signal mask)
- Y_UNIT_TEST(TestSignalMask) {
+ Y_UNIT_TEST(TestSignalMask) {
// block SIGTERM
int rc;
sigset_t newmask, oldmask;
@@ -365,7 +365,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
UNIT_ASSERT(!NFs::Exists(tmpfile));
// restore signal mask
- rc = SigProcMask(SIG_SETMASK, &oldmask, nullptr);
+ rc = SigProcMask(SIG_SETMASK, &oldmask, nullptr);
UNIT_ASSERT(rc == 0);
}
#else
@@ -380,10 +380,10 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) {
UNIT_ASSERT(cmd.GetExitCode().Defined() && 0 == cmd.GetExitCode());
}
#endif
- Y_UNIT_TEST(TestInternalError) {
+ Y_UNIT_TEST(TestInternalError) {
TString input = (TString("a") * 2000).append("\n");
TStringInput inputStream(input);
- TMemoryOutput outputStream(nullptr, 0);
+ TMemoryOutput outputStream(nullptr, 0);
TShellCommandOptions options;
options.SetInputStream(&inputStream);
options.SetOutputStream(&outputStream);
diff --git a/util/system/shmat.cpp b/util/system/shmat.cpp
index 663e63bc12..07ff0d6caa 100644
--- a/util/system/shmat.cpp
+++ b/util/system/shmat.cpp
@@ -91,7 +91,7 @@ namespace {
TSharedMemory::TSharedMemory()
: Handle(INVALID_FHANDLE)
- , Data(nullptr)
+ , Data(nullptr)
, Size(0)
{
}
@@ -102,7 +102,7 @@ static void FormatName(char* buf, const TGUID& id) {
}
bool TSharedMemory::Open(const TGUID& id, int size) {
- //Y_ASSERT(Data == 0);
+ //Y_ASSERT(Data == 0);
Id = id;
Size = size;
@@ -117,7 +117,7 @@ bool TSharedMemory::Open(const TGUID& id, int size) {
Data = MapViewOfFile(Handle, FILE_MAP_ALL_ACCESS, 0, 0, size);
if (Data == 0) {
- //Y_ASSERT(0);
+ //Y_ASSERT(0);
CloseHandle(Handle);
Handle = INVALID_OS_HANDLE;
@@ -128,7 +128,7 @@ bool TSharedMemory::Open(const TGUID& id, int size) {
}
bool TSharedMemory::Create(int size) {
- //Y_ASSERT(Data == 0);
+ //Y_ASSERT(Data == 0);
Size = size;
CreateGuid(&Id);
@@ -138,14 +138,14 @@ bool TSharedMemory::Create(int size) {
Handle = CreateFileMappingA(INVALID_OS_HANDLE, nullptr, PAGE_READWRITE, 0, size, name);
if (Handle == 0) {
- //Y_ASSERT(0);
+ //Y_ASSERT(0);
return false;
}
Data = MapViewOfFile(Handle, FILE_MAP_ALL_ACCESS, 0, 0, size);
if (Data == 0) {
- //Y_ASSERT(0);
+ //Y_ASSERT(0);
CloseHandle(Handle);
Handle = INVALID_OS_HANDLE;
@@ -172,7 +172,7 @@ static key_t GetKey(const TGUID& id) {
bool TSharedMemory::Open(const TGUID& id, int size) {
Y_VERIFY(id, "invalid shared memory guid: %s", GetGuidAsString(id).data());
- //Y_ASSERT(Data == 0);
+ //Y_ASSERT(Data == 0);
Size = size;
key_t k = GetKey(id);
@@ -182,10 +182,10 @@ bool TSharedMemory::Open(const TGUID& id, int size) {
return false;
}
- Data = shmat(shmId, nullptr, 0);
+ Data = shmat(shmId, nullptr, 0);
- if (Data == nullptr) {
- //Y_ASSERT(0);
+ if (Data == nullptr) {
+ //Y_ASSERT(0);
return false;
}
@@ -193,7 +193,7 @@ bool TSharedMemory::Open(const TGUID& id, int size) {
}
bool TSharedMemory::Create(int size) {
- //Y_ASSERT(Data == 0);
+ //Y_ASSERT(Data == 0);
Size = size;
CreateGuid(&Id);
@@ -202,14 +202,14 @@ bool TSharedMemory::Create(int size) {
Handle = shmget(k, Size, IPC_CREAT | IPC_EXCL | 0777);
if (Handle < 0) {
- //Y_ASSERT(0);
+ //Y_ASSERT(0);
return false;
}
Data = shmat(Handle, nullptr, 0);
if (Data == (void*)-1) {
- //Y_ASSERT(0);
+ //Y_ASSERT(0);
shmctl(Handle, IPC_RMID, nullptr);
Handle = -1;
diff --git a/util/system/shmat_ut.cpp b/util/system/shmat_ut.cpp
index 45921aaa88..9d92243ae7 100644
--- a/util/system/shmat_ut.cpp
+++ b/util/system/shmat_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TTestSharedMemory) {
- Y_UNIT_TEST(TestInProc) {
+Y_UNIT_TEST_SUITE(TTestSharedMemory) {
+ Y_UNIT_TEST(TestInProc) {
TSharedMemory m1;
TSharedMemory m2;
diff --git a/util/system/sigset.h b/util/system/sigset.h
index ed6f768e02..8dd02fd817 100644
--- a/util/system/sigset.h
+++ b/util/system/sigset.h
@@ -22,7 +22,7 @@ inline int SigEmptySet(sigset_t* set) {
#if defined _unix_
return sigemptyset(set);
#else
- Y_UNUSED(set);
+ Y_UNUSED(set);
return 0;
#endif
}
@@ -31,7 +31,7 @@ inline int SigFillSet(sigset_t* set) {
#if defined _unix_
return sigfillset(set);
#else
- Y_UNUSED(set);
+ Y_UNUSED(set);
return 0;
#endif
}
@@ -40,8 +40,8 @@ inline int SigAddSet(sigset_t* set, int signo) {
#if defined _unix_
return sigaddset(set, signo);
#else
- Y_UNUSED(set);
- Y_UNUSED(signo);
+ Y_UNUSED(set);
+ Y_UNUSED(signo);
return 0;
#endif
}
@@ -50,8 +50,8 @@ inline int SigDelSet(sigset_t* set, int signo) {
#if defined _unix_
return sigdelset(set, signo);
#else
- Y_UNUSED(set);
- Y_UNUSED(signo);
+ Y_UNUSED(set);
+ Y_UNUSED(signo);
return 0;
#endif
}
@@ -60,8 +60,8 @@ inline int SigIsMember(const sigset_t* set, int signo) {
#if defined _unix_
return sigismember(const_cast<sigset_t*>(set), signo);
#else
- Y_UNUSED(set);
- Y_UNUSED(signo);
+ Y_UNUSED(set);
+ Y_UNUSED(signo);
return 0;
#endif
}
@@ -70,9 +70,9 @@ inline int SigProcMask(int how, const sigset_t* set, sigset_t* oset) {
#if defined _unix_
return pthread_sigmask(how, set, oset);
#else
- Y_UNUSED(set);
- Y_UNUSED(oset);
- Y_UNUSED(how);
+ Y_UNUSED(set);
+ Y_UNUSED(oset);
+ Y_UNUSED(how);
return 0;
#endif
}
diff --git a/util/system/spinlock_ut.cpp b/util/system/spinlock_ut.cpp
index 384aafab0b..e8639a6404 100644
--- a/util/system/spinlock_ut.cpp
+++ b/util/system/spinlock_ut.cpp
@@ -2,7 +2,7 @@
#include "spinlock.h"
-Y_UNIT_TEST_SUITE(TSpinLock) {
+Y_UNIT_TEST_SUITE(TSpinLock) {
template <typename TLock>
void TestLock() {
TLock lock;
@@ -27,11 +27,11 @@ Y_UNIT_TEST_SUITE(TSpinLock) {
UNIT_ASSERT(!lock.IsLocked());
}
- Y_UNIT_TEST(TSpinLock_IsLocked) {
+ Y_UNIT_TEST(TSpinLock_IsLocked) {
TestLock<TSpinLock>();
}
- Y_UNIT_TEST(TAdaptiveLock_IsLocked) {
+ Y_UNIT_TEST(TAdaptiveLock_IsLocked) {
TestLock<TAdaptiveLock>();
}
}
diff --git a/util/system/src_location.cpp b/util/system/src_location.cpp
index 5d9ce4fd13..13ff1f24b3 100644
--- a/util/system/src_location.cpp
+++ b/util/system/src_location.cpp
@@ -5,7 +5,7 @@
#include <algorithm>
template <>
-void Out<TSourceLocation>(IOutputStream& o, const TSourceLocation& t) {
+void Out<TSourceLocation>(IOutputStream& o, const TSourceLocation& t) {
#if defined(_win_)
TString file(t.File);
std::replace(file.begin(), file.vend(), '\\', '/');
diff --git a/util/system/src_location.h b/util/system/src_location.h
index ed911e0169..12ba6e063e 100644
--- a/util/system/src_location.h
+++ b/util/system/src_location.h
@@ -5,7 +5,7 @@
#include <util/generic/strbuf.h>
struct TSourceLocation {
- constexpr TSourceLocation(const TStringBuf f, int l) noexcept
+ constexpr TSourceLocation(const TStringBuf f, int l) noexcept
: File(f)
, Line(l)
{
diff --git a/util/system/src_location_ut.cpp b/util/system/src_location_ut.cpp
index 400bf6d8d3..5b86cb86ef 100644
--- a/util/system/src_location_ut.cpp
+++ b/util/system/src_location_ut.cpp
@@ -8,8 +8,8 @@ static inline TString GenLoc() {
return TStringBuilder() << __LOCATION__;
}
-Y_UNIT_TEST_SUITE(TestLocation) {
- Y_UNIT_TEST(Test1) {
+Y_UNIT_TEST_SUITE(TestLocation) {
+ Y_UNIT_TEST(Test1) {
UNIT_ASSERT_VALUES_EQUAL(GenLoc(), "util/system/src_location_ut.cpp:8");
static constexpr TSourceLocation location = __LOCATION__;
diff --git a/util/system/src_root.h b/util/system/src_root.h
index 25f380f723..4f2d9f5ee6 100644
--- a/util/system/src_root.h
+++ b/util/system/src_root.h
@@ -7,19 +7,19 @@
namespace NPrivate {
struct TStaticBuf {
- constexpr TStaticBuf(const char* data, unsigned len) noexcept
+ constexpr TStaticBuf(const char* data, unsigned len) noexcept
: Data(data)
, Len(len)
{
}
template <class T>
- constexpr T As() const noexcept {
+ constexpr T As() const noexcept {
return T(Data, Len);
}
template <class T>
- constexpr operator T() const noexcept {
+ constexpr operator T() const noexcept {
return this->As<T>();
}
diff --git a/util/system/src_root_ut.cpp b/util/system/src_root_ut.cpp
index 57255786d4..e9a675eb9a 100644
--- a/util/system/src_root_ut.cpp
+++ b/util/system/src_root_ut.cpp
@@ -3,8 +3,8 @@
#include <util/folder/pathsplit.h>
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TestSourceRoot) {
- Y_UNIT_TEST(TestStrip) {
+Y_UNIT_TEST_SUITE(TestSourceRoot) {
+ Y_UNIT_TEST(TestStrip) {
// Reconstruct() converts "\" -> "/" on Windows
const TString path = TPathSplit(__SOURCE_FILE_IMPL__.As<TStringBuf>()).Reconstruct();
UNIT_ASSERT_EQUAL(path, "util" LOCSLASH_S "system" LOCSLASH_S "src_root_ut.cpp");
diff --git a/util/system/sys_alloc.h b/util/system/sys_alloc.h
index 0a4516bc53..4221a28f8c 100644
--- a/util/system/sys_alloc.h
+++ b/util/system/sys_alloc.h
@@ -1,14 +1,14 @@
#pragma once
-#include <util/system/compiler.h>
-
+#include <util/system/compiler.h>
+
#include <cstdlib>
#include <new>
inline void* y_allocate(size_t n) {
void* r = malloc(n);
- if (r == nullptr) {
+ if (r == nullptr) {
throw std::bad_alloc();
}
@@ -35,7 +35,7 @@ inline void* y_reallocate(void* p, size_t new_sz) {
void* r = realloc(p, new_sz);
- if (r == nullptr) {
+ if (r == nullptr) {
throw std::bad_alloc();
}
diff --git a/util/system/tempfile_ut.cpp b/util/system/tempfile_ut.cpp
index f8e2bb5e5b..e4a0923d0b 100644
--- a/util/system/tempfile_ut.cpp
+++ b/util/system/tempfile_ut.cpp
@@ -8,8 +8,8 @@
#include <algorithm>
-Y_UNIT_TEST_SUITE(TTempFileHandle) {
- Y_UNIT_TEST(Create) {
+Y_UNIT_TEST_SUITE(TTempFileHandle) {
+ Y_UNIT_TEST(Create) {
TString path;
{
TTempFileHandle tmp;
diff --git a/util/system/thread.cpp b/util/system/thread.cpp
index f51bc31d1d..6236746c2d 100644
--- a/util/system/thread.cpp
+++ b/util/system/thread.cpp
@@ -128,9 +128,9 @@ namespace {
//do not do this, kids, at home
P_->Ref();
#if _WIN32_WINNT < 0x0502
- Handle = reinterpret_cast<HANDLE>(::_beginthreadex(nullptr, (unsigned)StackSize(*P_), Proxy, (void*)P_.Get(), 0, &ThreadId));
+ Handle = reinterpret_cast<HANDLE>(::_beginthreadex(nullptr, (unsigned)StackSize(*P_), Proxy, (void*)P_.Get(), 0, &ThreadId));
#else
- Handle = reinterpret_cast<HANDLE>(::_beginthreadex(nullptr, (unsigned)StackSize(*P_), Proxy, (void*)P_.Get(), 0, nullptr));
+ Handle = reinterpret_cast<HANDLE>(::_beginthreadex(nullptr, (unsigned)StackSize(*P_), Proxy, (void*)P_.Get(), 0, nullptr));
#endif
if (!Handle) {
@@ -163,7 +163,7 @@ namespace {
public:
inline TPosixThread(const TParams& params)
: P_(new TParams(params))
- , H_()
+ , H_()
{
static_assert(sizeof(H_) == sizeof(TId), "expect sizeof(H_) == sizeof(TId)");
}
@@ -173,7 +173,7 @@ namespace {
}
inline void* Join() {
- void* tec = nullptr;
+ void* tec = nullptr;
PCHECK(pthread_join(H_, &tec), "can not join thread");
return tec;
@@ -188,7 +188,7 @@ namespace {
}
inline void Start() {
- pthread_attr_t* pattrs = nullptr;
+ pthread_attr_t* pattrs = nullptr;
pthread_attr_t attrs;
if (P_->StackSize > 0) {
@@ -302,7 +302,7 @@ void* TThread::Join() {
return ret;
}
- return nullptr;
+ return nullptr;
}
void TThread::Detach() {
@@ -363,8 +363,8 @@ namespace {
}
}
-ISimpleThread::ISimpleThread(size_t stackSize)
- : TThread(TParams(ThreadProcWrapper<ISimpleThread>, reinterpret_cast<void*>(this), stackSize))
+ISimpleThread::ISimpleThread(size_t stackSize)
+ : TThread(TParams(ThreadProcWrapper<ISimpleThread>, reinterpret_cast<void*>(this), stackSize))
{
}
@@ -470,36 +470,36 @@ void TThread::SetCurrentThreadName(const char* name) {
}
TString TThread::CurrentThreadName() {
-#if defined(_freebsd_)
+#if defined(_freebsd_)
// TODO: check pthread_get_name_np API availability
-#elif defined(_linux_)
- // > The buffer should allow space for up to 16 bytes; the returned string will be
- // > null-terminated.
- // via `man prctl`
- char name[16];
- memset(name, 0, sizeof(name));
- Y_VERIFY(prctl(PR_GET_NAME, name, 0, 0, 0) == 0, "pctl failed: %s", strerror(errno));
- return name;
-#elif defined(_darwin_)
- // available on Mac OS 10.6+
- const auto thread = pthread_self();
- char name[256];
- memset(name, 0, sizeof(name));
- Y_VERIFY(pthread_getname_np(thread, name, sizeof(name)) == 0, "pthread_getname_np failed: %s", strerror(errno));
- return name;
+#elif defined(_linux_)
+ // > The buffer should allow space for up to 16 bytes; the returned string will be
+ // > null-terminated.
+ // via `man prctl`
+ char name[16];
+ memset(name, 0, sizeof(name));
+ Y_VERIFY(prctl(PR_GET_NAME, name, 0, 0, 0) == 0, "pctl failed: %s", strerror(errno));
+ return name;
+#elif defined(_darwin_)
+ // available on Mac OS 10.6+
+ const auto thread = pthread_self();
+ char name[256];
+ memset(name, 0, sizeof(name));
+ Y_VERIFY(pthread_getname_np(thread, name, sizeof(name)) == 0, "pthread_getname_np failed: %s", strerror(errno));
+ return name;
#elif defined(_win_)
auto api = Singleton<TWinThreadDescrAPI>();
if (api->HasAPI()) {
return api->GetDescr();
}
return {};
-#else
+#else
// no idea
-#endif // OS
-
- return {};
-}
-
+#endif // OS
+
+ return {};
+}
+
bool TThread::CanGetCurrentThreadName() {
#if defined(_linux_) || defined(_darwin_)
return true;
diff --git a/util/system/thread.h b/util/system/thread.h
index 1db7af6adb..a6e8abdb5b 100644
--- a/util/system/thread.h
+++ b/util/system/thread.h
@@ -8,7 +8,7 @@
#include <util/generic/string.h>
#include "defaults.h"
-#include "progname.h"
+#include "progname.h"
bool SetHighestThreadPriority();
@@ -27,11 +27,11 @@ public:
size_t StackSize;
void* StackPointer;
// See comments for `SetCurrentThreadName`
- TString Name = GetProgramName();
+ TString Name = GetProgramName();
inline TParams()
- : Proc(nullptr)
- , Data(nullptr)
+ : Proc(nullptr)
+ , Data(nullptr)
, StackSize(0)
, StackPointer(nullptr)
{
@@ -103,24 +103,24 @@ public:
static TId ImpossibleThreadId() noexcept;
static TId CurrentThreadId() noexcept;
-
+
/*
* Returns numeric thread id, as visible in e. g. htop.
* Consider using this value for logging.
*/
static TId CurrentThreadNumericId() noexcept;
- // NOTE: Content of `name` will be copied.
- //
- // NOTE: On Linux thread name is limited to 15 symbols which is probably the smallest one among
+ // NOTE: Content of `name` will be copied.
+ //
+ // NOTE: On Linux thread name is limited to 15 symbols which is probably the smallest one among
// all platforms. If you provide a name longer than 15 symbols it will be cut. So if you expect
// `CurrentThreadName` to return the same name as `name` make sure it's not longer than 15
- // symbols.
+ // symbols.
static void SetCurrentThreadName(const char* name);
// NOTE: Will return empty string where CanGetCurrentThreadName() returns false.
static TString CurrentThreadName();
-
+
// NOTE: Depends on a platform version.
// Will return true for Darwin, Linux or fresh Windows 10.
static bool CanGetCurrentThreadName();
@@ -157,11 +157,11 @@ private:
THolder<TImpl> Impl_;
};
-class ISimpleThread: public TThread {
+class ISimpleThread: public TThread {
public:
- ISimpleThread(size_t stackSize = 0);
+ ISimpleThread(size_t stackSize = 0);
- virtual ~ISimpleThread() = default;
+ virtual ~ISimpleThread() = default;
virtual void* ThreadProc() = 0;
};
diff --git a/util/system/thread_ut.cpp b/util/system/thread_ut.cpp
index d47c409765..d820898fd5 100644
--- a/util/system/thread_ut.cpp
+++ b/util/system/thread_ut.cpp
@@ -4,10 +4,10 @@
#include <atomic>
-Y_UNIT_TEST_SUITE(TSysThreadTest) {
+Y_UNIT_TEST_SUITE(TSysThreadTest) {
struct TIdTester {
inline TIdTester()
- : Thr(nullptr)
+ : Thr(nullptr)
, Cur(0)
, Real(0)
{
@@ -16,7 +16,7 @@ Y_UNIT_TEST_SUITE(TSysThreadTest) {
static inline void* DoRun(void* ptr) {
((TIdTester*)ptr)->Run();
- return nullptr;
+ return nullptr;
}
inline void Run() {
@@ -31,7 +31,7 @@ Y_UNIT_TEST_SUITE(TSysThreadTest) {
TThread::TId Numeric;
};
- Y_UNIT_TEST(TestThreadId) {
+ Y_UNIT_TEST(TestThreadId) {
TIdTester tst;
TThread thr(tst.DoRun, &tst);
@@ -48,131 +48,131 @@ Y_UNIT_TEST_SUITE(TSysThreadTest) {
void* ThreadProc(void*) {
TThread::SetCurrentThreadName("CurrentThreadSetNameTest");
- return nullptr;
+ return nullptr;
}
void* ThreadProc2(void*) {
- return nullptr;
+ return nullptr;
}
- void* ThreadProc3(void*) {
+ void* ThreadProc3(void*) {
const auto name = TThread::CurrentThreadName();
- Y_FAKE_READ(name);
- return nullptr;
- }
-
- void* ThreadProc4(void*) {
- const TString setName = "ThreadName";
+ Y_FAKE_READ(name);
+ return nullptr;
+ }
+
+ void* ThreadProc4(void*) {
+ const TString setName = "ThreadName";
TThread::SetCurrentThreadName(setName.data());
-
+
const auto getName = TThread::CurrentThreadName();
if (TThread::CanGetCurrentThreadName()) {
UNIT_ASSERT_VALUES_EQUAL(setName, getName);
} else {
UNIT_ASSERT_VALUES_EQUAL("", getName);
}
- return nullptr;
- }
-
- void* ThreadProcChild(void*) {
+ return nullptr;
+ }
+
+ void* ThreadProcChild(void*) {
const auto name = TThread::CurrentThreadName();
- const auto defaultName = GetProgramName();
-
- (void)name;
- (void)defaultName;
-
-#if defined(_darwin_) || defined(_linux_)
- UNIT_ASSERT_VALUES_EQUAL(name, defaultName);
-#endif
- return nullptr;
- }
-
- void* ThreadProcParent(void*) {
- const TString setName = "Parent";
+ const auto defaultName = GetProgramName();
+
+ (void)name;
+ (void)defaultName;
+
+#if defined(_darwin_) || defined(_linux_)
+ UNIT_ASSERT_VALUES_EQUAL(name, defaultName);
+#endif
+ return nullptr;
+ }
+
+ void* ThreadProcParent(void*) {
+ const TString setName = "Parent";
TThread::SetCurrentThreadName(setName.data());
-
- TThread thread(&ThreadProcChild, nullptr);
-
- thread.Start();
- thread.Join();
-
+
+ TThread thread(&ThreadProcChild, nullptr);
+
+ thread.Start();
+ thread.Join();
+
const auto getName = TThread::CurrentThreadName();
if (TThread::CanGetCurrentThreadName()) {
UNIT_ASSERT_VALUES_EQUAL(setName, getName);
} else {
UNIT_ASSERT_VALUES_EQUAL("", getName);
}
- return nullptr;
- }
-
- Y_UNIT_TEST(TestSetThreadName) {
- TThread thread(&ThreadProc, nullptr);
+ return nullptr;
+ }
+
+ Y_UNIT_TEST(TestSetThreadName) {
+ TThread thread(&ThreadProc, nullptr);
// just check it doesn't crash
thread.Start();
thread.Join();
}
- Y_UNIT_TEST(TestSetThreadName2) {
- TThread thread(TThread::TParams(&ThreadProc, nullptr, 0).SetName("XXX"));
+ Y_UNIT_TEST(TestSetThreadName2) {
+ TThread thread(TThread::TParams(&ThreadProc, nullptr, 0).SetName("XXX"));
+
+ thread.Start();
+ thread.Join();
+ }
+
+ Y_UNIT_TEST(TestGetThreadName) {
+ TThread thread(&ThreadProc3, nullptr);
+ thread.Start();
+ thread.Join();
+ }
+
+ Y_UNIT_TEST(TestSetGetThreadName) {
+ TThread thread(&ThreadProc4, nullptr);
+ thread.Start();
+ thread.Join();
+ }
+ Y_UNIT_TEST(TestSetGetThreadNameInChildThread) {
+ TThread thread(&ThreadProcParent, nullptr);
thread.Start();
thread.Join();
}
- Y_UNIT_TEST(TestGetThreadName) {
- TThread thread(&ThreadProc3, nullptr);
- thread.Start();
- thread.Join();
- }
-
- Y_UNIT_TEST(TestSetGetThreadName) {
- TThread thread(&ThreadProc4, nullptr);
- thread.Start();
- thread.Join();
- }
-
- Y_UNIT_TEST(TestSetGetThreadNameInChildThread) {
- TThread thread(&ThreadProcParent, nullptr);
- thread.Start();
- thread.Join();
- }
-
- Y_UNIT_TEST(TestDoubleJoin) {
- TThread thread(&ThreadProc, nullptr);
+ Y_UNIT_TEST(TestDoubleJoin) {
+ TThread thread(&ThreadProc, nullptr);
thread.Start();
thread.Join();
- UNIT_ASSERT_EQUAL(thread.Join(), nullptr);
+ UNIT_ASSERT_EQUAL(thread.Join(), nullptr);
}
- Y_UNIT_TEST(TestDoubleStart) {
- TThread thread(&ThreadProc, nullptr);
+ Y_UNIT_TEST(TestDoubleStart) {
+ TThread thread(&ThreadProc, nullptr);
thread.Start();
UNIT_ASSERT_EXCEPTION(thread.Start(), yexception);
thread.Join();
}
- Y_UNIT_TEST(TestNoStart) {
- TThread thread(&ThreadProc, nullptr);
+ Y_UNIT_TEST(TestNoStart) {
+ TThread thread(&ThreadProc, nullptr);
}
- Y_UNIT_TEST(TestNoStartJoin) {
- TThread thread(&ThreadProc, nullptr);
+ Y_UNIT_TEST(TestNoStartJoin) {
+ TThread thread(&ThreadProc, nullptr);
- UNIT_ASSERT_EQUAL(thread.Join(), nullptr);
+ UNIT_ASSERT_EQUAL(thread.Join(), nullptr);
}
- Y_UNIT_TEST(TestStackPointer) {
+ Y_UNIT_TEST(TestStackPointer) {
TArrayHolder<char> buf(new char[64000]);
- TThread thr(TThread::TParams(ThreadProc2, nullptr).SetStackPointer(buf.Get()).SetStackSize(64000));
+ TThread thr(TThread::TParams(ThreadProc2, nullptr).SetStackPointer(buf.Get()).SetStackSize(64000));
thr.Start();
UNIT_ASSERT_VALUES_EQUAL(thr.Join(), nullptr);
}
- Y_UNIT_TEST(TestStackLimits) {
+ Y_UNIT_TEST(TestStackLimits) {
TCurrentThreadLimits sl;
UNIT_ASSERT(sl.StackBegin);
diff --git a/util/system/tls.cpp b/util/system/tls.cpp
index 74400efea2..c2f1a04a14 100644
--- a/util/system/tls.cpp
+++ b/util/system/tls.cpp
@@ -41,7 +41,7 @@ namespace {
class TStoredValue: public TIntrusiveListItem<TStoredValue> {
public:
inline TStoredValue(const TKey* key)
- : Data_(nullptr)
+ : Data_(nullptr)
, Dtor_(key->Dtor)
{
}
@@ -98,7 +98,7 @@ namespace {
};
inline TPerThreadStorage* MyStorage() {
-#if defined(Y_HAVE_FAST_POD_TLS)
+#if defined(Y_HAVE_FAST_POD_TLS)
Y_POD_STATIC_THREAD(TPerThreadStorage*)
my(nullptr);
@@ -123,14 +123,14 @@ namespace {
class TMasterTls: public TGenericTlsBase {
public:
inline TMasterTls() {
- Y_VERIFY(!pthread_key_create(&Key_, Dtor), "pthread_key_create failed");
+ Y_VERIFY(!pthread_key_create(&Key_, Dtor), "pthread_key_create failed");
}
inline ~TMasterTls() override {
//explicitly call dtor for main thread
Dtor(pthread_getspecific(Key_));
- Y_VERIFY(!pthread_key_delete(Key_), "pthread_key_delete failed");
+ Y_VERIFY(!pthread_key_delete(Key_), "pthread_key_delete failed");
}
static inline TMasterTls* Instance() {
@@ -144,7 +144,7 @@ namespace {
if (!ret) {
ret = new TPerThreadStorage();
- Y_VERIFY(!pthread_setspecific(Key_, ret), "pthread_setspecific failed");
+ Y_VERIFY(!pthread_setspecific(Key_, ret), "pthread_setspecific failed");
}
return (TPerThreadStorage*)ret;
diff --git a/util/system/tls.h b/util/system/tls.h
index 3cc297b8ae..3c4f56dbeb 100644
--- a/util/system/tls.h
+++ b/util/system/tls.h
@@ -20,7 +20,7 @@
#endif
/**
- @def Y_THREAD(TType)
+ @def Y_THREAD(TType)
A thread-local wrapper for a given class. Suitable for POD and classes with a constructor with a single argument.
@@ -46,7 +46,7 @@
Example:
@code
//the field declaration in header
- Y_THREAD(TBuffer) TmpBuffer;
+ Y_THREAD(TBuffer) TmpBuffer;
//...later somewhere in cpp...
TmpBuffer.Clear();
for (size_t i = 0; i < sz && TrieCursor[i].second.IsFork(); ++i) {
@@ -57,10 +57,10 @@
Example:
@code
//the field decalrataion in header
- Y_THREAD(TMyWriter*) ThreadLocalWriter;
+ Y_THREAD(TMyWriter*) ThreadLocalWriter;
//...later somewhere in cpp...
TMyWriter*& writerRef = ThreadLocalWriter.Get();
- if (writerRef == nullptr) {
+ if (writerRef == nullptr) {
THolder<TMyWriter> threadLocalWriter( new TMyWriter(
*Session,
MinLogError,
@@ -84,7 +84,7 @@
Example:
@code
- Y_THREAD(TScoreCalcer*) ScoreCalcerPtr;
+ Y_THREAD(TScoreCalcer*) ScoreCalcerPtr;
static TScoreCalcer* GetScoreCalcer(yint maxElemCount) {
if (ScoreCalcerPtr == 0) {
ScoreCalcerPtr = new TScoreCalcer();
@@ -98,35 +98,35 @@
**/
/**
- @def Y_STATIC_THREAD(TType)
+ @def Y_STATIC_THREAD(TType)
- Equivalent to "static Y_THREAD(TType)"
+ Equivalent to "static Y_THREAD(TType)"
- @see Y_THREAD(TType)
+ @see Y_THREAD(TType)
**/
/**
- @def Y_POD_THREAD(TType)
+ @def Y_POD_THREAD(TType)
- Same interface as Y_THREAD(TType), but TType must be a POD.
- Implemented (based on the compiler) as Y_THREAD(TType) or as native tls.
+ Same interface as Y_THREAD(TType), but TType must be a POD.
+ Implemented (based on the compiler) as Y_THREAD(TType) or as native tls.
- @see Y_THREAD(TType)
+ @see Y_THREAD(TType)
**/
/**
@def STATIC_POD_THREAD(TType)
- Equivalent to "static Y_POD_THREAD(TType)"
+ Equivalent to "static Y_POD_THREAD(TType)"
- @see Y_POD_THREAD(TType)
+ @see Y_POD_THREAD(TType)
**/
-#define Y_THREAD(T) ::NTls::TValue<T>
-#define Y_STATIC_THREAD(T) static Y_THREAD(T)
+#define Y_THREAD(T) ::NTls::TValue<T>
+#define Y_STATIC_THREAD(T) static Y_THREAD(T)
// gcc and msvc support automatic tls for POD types
-#if defined(Y_DISABLE_THRKEY_OPTIMIZATION)
+#if defined(Y_DISABLE_THRKEY_OPTIMIZATION)
// nothing to do
#elif defined(__clang__)
#define Y_POD_THREAD(T) thread_local T
@@ -140,7 +140,7 @@
#define Y_POD_STATIC_THREAD(T) __declspec(thread) static T
#endif
-#if !defined(Y_POD_THREAD) || !defined(Y_POD_STATIC_THREAD)
+#if !defined(Y_POD_THREAD) || !defined(Y_POD_STATIC_THREAD)
#define Y_POD_THREAD(T) Y_THREAD(T)
#define Y_POD_STATIC_THREAD(T) Y_STATIC_THREAD(T)
#else
diff --git a/util/system/tls_ut.cpp b/util/system/tls_ut.cpp
index 586919b781..e84d34b42a 100644
--- a/util/system/tls_ut.cpp
+++ b/util/system/tls_ut.cpp
@@ -3,7 +3,7 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TTestTLS) {
+Y_UNIT_TEST_SUITE(TTestTLS) {
struct X {
inline X()
: V(0)
@@ -22,10 +22,10 @@ Y_UNIT_TEST_SUITE(TTestTLS) {
V;
};
- Y_UNIT_TEST(TestHugeSetup) {
+ Y_UNIT_TEST(TestHugeSetup) {
TArrayHolder<X> x(new X[100000]);
- struct TThr: public ISimpleThread {
+ struct TThr: public ISimpleThread {
inline TThr(X* ptr)
: P(ptr)
{
diff --git a/util/system/type_name.cpp b/util/system/type_name.cpp
index 811b90b85f..0377da4212 100644
--- a/util/system/type_name.cpp
+++ b/util/system/type_name.cpp
@@ -29,7 +29,7 @@ const char* NPrivate::TCppDemangler::Demangle(const char* name) {
return name;
#else
int status;
- TmpBuf_.Reset(__cxxabiv1::__cxa_demangle(name, nullptr, nullptr, &status));
+ TmpBuf_.Reset(__cxxabiv1::__cxa_demangle(name, nullptr, nullptr, &status));
if (!TmpBuf_) {
return name;
diff --git a/util/system/type_name_ut.cpp b/util/system/type_name_ut.cpp
index 518b257965..86597f4232 100644
--- a/util/system/type_name_ut.cpp
+++ b/util/system/type_name_ut.cpp
@@ -8,8 +8,8 @@
#include <stdexcept>
#include <string>
-Y_UNIT_TEST_SUITE(TDemangleTest) {
- Y_UNIT_TEST(SimpleTest) {
+Y_UNIT_TEST_SUITE(TDemangleTest) {
+ Y_UNIT_TEST(SimpleTest) {
// just check it does not crash or leak
CppDemangle("hello");
CppDemangle("");
diff --git a/util/system/types_ut.cpp b/util/system/types_ut.cpp
index 4a7c96cfa7..19e40cef46 100644
--- a/util/system/types_ut.cpp
+++ b/util/system/types_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TestTypes) {
- Y_UNIT_TEST(TestScanf) {
+Y_UNIT_TEST_SUITE(TestTypes) {
+ Y_UNIT_TEST(TestScanf) {
i32 val32 = 0;
sscanf("-123", "%" SCNi32, &val32);
UNIT_ASSERT(val32 == -123);
diff --git a/util/system/unaligned_mem.h b/util/system/unaligned_mem.h
index 6985270d9e..4b84686f2f 100644
--- a/util/system/unaligned_mem.h
+++ b/util/system/unaligned_mem.h
@@ -1,7 +1,7 @@
#pragma once
#include "defaults.h"
-#include "yassert.h"
+#include "yassert.h"
#include <string.h>
#include <type_traits>
@@ -23,45 +23,45 @@ template <class T>
inline void WriteUnaligned(void* to, const std::remove_reference_t<T>& t) noexcept {
memcpy(to, &t, sizeof(T));
}
-
-template <class T, unsigned Align = sizeof(T)>
-class TUnalignedMemoryIterator {
-public:
- inline TUnalignedMemoryIterator(const void* buf, size_t len)
- : C_((const unsigned char*)buf)
- , E_(C_ + len)
- , L_(E_ - (len % Align))
- {
- Y_FAKE_READ(buf);
- }
-
- inline bool AtEnd() const noexcept {
- return C_ == L_;
- }
-
- inline T Cur() const noexcept {
+
+template <class T, unsigned Align = sizeof(T)>
+class TUnalignedMemoryIterator {
+public:
+ inline TUnalignedMemoryIterator(const void* buf, size_t len)
+ : C_((const unsigned char*)buf)
+ , E_(C_ + len)
+ , L_(E_ - (len % Align))
+ {
+ Y_FAKE_READ(buf);
+ }
+
+ inline bool AtEnd() const noexcept {
+ return C_ == L_;
+ }
+
+ inline T Cur() const noexcept {
Y_ASSERT(C_ < L_ || sizeof(T) < Align);
- return ::ReadUnaligned<T>(C_);
- }
-
- inline T Next() noexcept {
- T ret(Cur());
-
- C_ += sizeof(T);
-
- return ret;
- }
-
- inline const unsigned char* Last() const noexcept {
- return C_;
- }
-
- inline size_t Left() const noexcept {
- return E_ - C_;
- }
-
-private:
- const unsigned char* C_;
- const unsigned char* E_;
- const unsigned char* L_;
-};
+ return ::ReadUnaligned<T>(C_);
+ }
+
+ inline T Next() noexcept {
+ T ret(Cur());
+
+ C_ += sizeof(T);
+
+ return ret;
+ }
+
+ inline const unsigned char* Last() const noexcept {
+ return C_;
+ }
+
+ inline size_t Left() const noexcept {
+ return E_ - C_;
+ }
+
+private:
+ const unsigned char* C_;
+ const unsigned char* E_;
+ const unsigned char* L_;
+};
diff --git a/util/system/unaligned_mem_ut.cpp b/util/system/unaligned_mem_ut.cpp
index fddf98f8de..9de3f3e931 100644
--- a/util/system/unaligned_mem_ut.cpp
+++ b/util/system/unaligned_mem_ut.cpp
@@ -29,8 +29,8 @@ namespace {
}
#endif
-Y_UNIT_TEST_SUITE(UnalignedMem) {
- Y_UNIT_TEST(TestReadWrite) {
+Y_UNIT_TEST_SUITE(UnalignedMem) {
+ Y_UNIT_TEST(TestReadWrite) {
alignas(ui64) char buf[100];
WriteUnaligned<ui16>(buf + 1, (ui16)1);
@@ -42,7 +42,7 @@ Y_UNIT_TEST_SUITE(UnalignedMem) {
UNIT_ASSERT_VALUES_EQUAL(ReadUnaligned<ui64>(buf + 1 + 2 + 4), 3);
}
- Y_UNIT_TEST(TestReadWriteRuntime) {
+ Y_UNIT_TEST(TestReadWriteRuntime) {
// Unlike the test above, this test avoids compile-time execution by a smart compiler.
// It is required to catch the SIGSEGV in case compiler emits an alignment-sensitive instruction.
@@ -69,14 +69,14 @@ Y_UNIT_TEST_SUITE(UnalignedMem) {
UNIT_ASSERT_VALUES_EQUAL(val3, 3);
}
#ifdef Y_HAVE_INT128
- Y_UNIT_TEST(TestReadWrite128) {
+ Y_UNIT_TEST(TestReadWrite128) {
alignas(TUInt128) char buf[100] = {0};
WriteUnaligned<TUInt128>(buf + 1, TUInt128::Max());
auto val = ReadUnaligned<TUInt128>(buf + 1);
UNIT_ASSERT(val == TUInt128::Max());
}
- Y_UNIT_TEST(TestReadWriteRuntime128) {
+ Y_UNIT_TEST(TestReadWriteRuntime128) {
// Unlike the test above, this test avoids compile-time execution by a smart compiler.
// It is required to catch the SIGSEGV in case compiler emits an alignment-sensitive instruction.
diff --git a/util/system/user_ut.cpp b/util/system/user_ut.cpp
index 49ed264475..4f8a5ce2ef 100644
--- a/util/system/user_ut.cpp
+++ b/util/system/user_ut.cpp
@@ -2,8 +2,8 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(TestUser) {
- Y_UNIT_TEST(TestNotEmpty) {
+Y_UNIT_TEST_SUITE(TestUser) {
+ Y_UNIT_TEST(TestNotEmpty) {
UNIT_ASSERT(GetUsername());
}
}
diff --git a/util/system/utime.cpp b/util/system/utime.cpp
index 347467f28f..c7bfc4bf3d 100644
--- a/util/system/utime.cpp
+++ b/util/system/utime.cpp
@@ -9,7 +9,7 @@
#endif
int TouchFile(const char* filePath) {
- return utime(filePath, nullptr);
+ return utime(filePath, nullptr);
}
int SetModTime(const char* filePath, time_t modtime, time_t actime) {
diff --git a/util/system/yassert.cpp b/util/system/yassert.cpp
index cf53876f49..0f586648b7 100644
--- a/util/system/yassert.cpp
+++ b/util/system/yassert.cpp
@@ -1,21 +1,21 @@
#include "yassert.h"
-#include "backtrace.h"
+#include "backtrace.h"
#include "guard.h"
#include "spinlock.h"
-#include "src_root.h"
-
+#include "src_root.h"
+
#include <util/datetime/base.h>
-#include <util/generic/singleton.h>
+#include <util/generic/singleton.h>
#include <util/generic/strbuf.h>
#include <util/generic/string.h>
-#include <util/stream/output.h>
-#include <util/stream/str.h>
-#include <util/string/printf.h>
+#include <util/stream/output.h>
+#include <util/stream/str.h>
+#include <util/string/printf.h>
-#include <cstdlib>
-#include <stdarg.h>
-#include <stdio.h>
+#include <cstdlib>
+#include <stdarg.h>
+#include <stdio.h>
#ifdef CLANG_COVERAGE
extern "C" {
diff --git a/util/system/yassert.h b/util/system/yassert.h
index 530a82174c..529823440c 100644
--- a/util/system/yassert.h
+++ b/util/system/yassert.h
@@ -54,7 +54,7 @@ inline void YaDebugBreak() {
__debugbreak();
}
-#undef Y_ASSERT
+#undef Y_ASSERT
#if !defined(NDEBUG) && !defined(__GCCXML__)
#define Y_ASSERT(a) \
@@ -95,16 +95,16 @@ namespace NPrivate {
}
/// Assert that does not depend on NDEBUG macro and outputs message like printf
-#define Y_VERIFY(expr, ...) \
+#define Y_VERIFY(expr, ...) \
do { \
if (Y_UNLIKELY(!(expr))) { \
::NPrivate::Panic(__SOURCE_FILE_IMPL__, __LINE__, __FUNCTION__, #expr, " " __VA_ARGS__); \
} \
} while (false)
-#define Y_FAIL(...) \
- do { \
- ::NPrivate::Panic(__SOURCE_FILE_IMPL__, __LINE__, __FUNCTION__, nullptr, " " __VA_ARGS__); \
+#define Y_FAIL(...) \
+ do { \
+ ::NPrivate::Panic(__SOURCE_FILE_IMPL__, __LINE__, __FUNCTION__, nullptr, " " __VA_ARGS__); \
} while (false)
#ifndef NDEBUG
diff --git a/util/system/yassert_ut.cpp b/util/system/yassert_ut.cpp
index 56d6122d0f..ddd392666c 100644
--- a/util/system/yassert_ut.cpp
+++ b/util/system/yassert_ut.cpp
@@ -4,32 +4,32 @@
#include <library/cpp/testing/unittest/registar.h>
-Y_UNIT_TEST_SUITE(YassertTest) {
- Y_UNIT_TEST(TestAcsLikeFunctionCall) {
+Y_UNIT_TEST_SUITE(YassertTest) {
+ Y_UNIT_TEST(TestAcsLikeFunctionCall) {
if (true) {
- Y_ASSERT(true); // this cannot be compiled if Y_ASSERT is "if (!cond) { ... }"
+ Y_ASSERT(true); // this cannot be compiled if Y_ASSERT is "if (!cond) { ... }"
} else {
- Y_ASSERT(false);
+ Y_ASSERT(false);
}
bool var = false;
if (false) {
- Y_ASSERT(false);
+ Y_ASSERT(false);
} else {
- var = true; // this is unreachable if Y_ASSERT is "if (!cond) { ... }"
+ var = true; // this is unreachable if Y_ASSERT is "if (!cond) { ... }"
}
UNIT_ASSERT(var);
}
- Y_UNIT_TEST(TestFailCompiles) {
+ Y_UNIT_TEST(TestFailCompiles) {
if (false) {
- Y_FAIL("%d is a lucky number", 7);
- Y_FAIL();
+ Y_FAIL("%d is a lucky number", 7);
+ Y_FAIL();
}
}
- Y_UNIT_TEST(TestVerify) {
- Y_VERIFY(true, "hi %s", "there");
- Y_VERIFY(true);
+ Y_UNIT_TEST(TestVerify) {
+ Y_VERIFY(true, "hi %s", "there");
+ Y_VERIFY(true);
}
}
diff --git a/util/tests/benchmark/ya.make b/util/tests/benchmark/ya.make
index 6d10166908..134cbfabd1 100644
--- a/util/tests/benchmark/ya.make
+++ b/util/tests/benchmark/ya.make
@@ -1,11 +1,11 @@
OWNER(g:util)
SUBSCRIBER(g:util-subscribers)
-
-RECURSE_ROOT_RELATIVE(
- util/charset/benchmark
- util/generic/benchmark
- util/random/benchmark
+
+RECURSE_ROOT_RELATIVE(
+ util/charset/benchmark
+ util/generic/benchmark
+ util/random/benchmark
util/memory/benchmark
- util/string/benchmark
- util/system/benchmark
-)
+ util/string/benchmark
+ util/system/benchmark
+)
diff --git a/util/tests/fuzzing/ya.make b/util/tests/fuzzing/ya.make
index e80168e3bc..d9a8f9df9f 100644
--- a/util/tests/fuzzing/ya.make
+++ b/util/tests/fuzzing/ya.make
@@ -1,7 +1,7 @@
OWNER(g:util)
SUBSCRIBER(g:util-subscribers)
-
-RECURSE_ROOT_RELATIVE(
- util/string/fuzzing
+
+RECURSE_ROOT_RELATIVE(
+ util/string/fuzzing
util/generic/fuzz
-)
+)
diff --git a/util/thread/factory.cpp b/util/thread/factory.cpp
index 0336a25876..48e898f32d 100644
--- a/util/thread/factory.cpp
+++ b/util/thread/factory.cpp
@@ -35,7 +35,7 @@ namespace {
static void* ThreadProc(void* func) {
((IThreadAble*)(func))->Execute();
- return nullptr;
+ return nullptr;
}
private:
diff --git a/util/thread/fwd.cpp b/util/thread/fwd.cpp
index 2261ef316c..4214b6df83 100644
--- a/util/thread/fwd.cpp
+++ b/util/thread/fwd.cpp
@@ -1 +1 @@
-#include "fwd.h"
+#include "fwd.h"
diff --git a/util/thread/fwd.h b/util/thread/fwd.h
index 78f81c8c52..6f1caed21c 100644
--- a/util/thread/fwd.h
+++ b/util/thread/fwd.h
@@ -1,30 +1,30 @@
-#pragma once
-
-#include <stlfwd>
-
-struct TDefaultLFCounter;
-
-template <class T, class TCounter = TDefaultLFCounter>
-class TLockFreeQueue;
-
-template <class T, class TCounter = TDefaultLFCounter>
-class TAutoLockFreeQueue;
-
-template <class T>
+#pragma once
+
+#include <stlfwd>
+
+struct TDefaultLFCounter;
+
+template <class T, class TCounter = TDefaultLFCounter>
+class TLockFreeQueue;
+
+template <class T, class TCounter = TDefaultLFCounter>
+class TAutoLockFreeQueue;
+
+template <class T>
class TLockFreeStack;
-
+
class IThreadFactory;
-
-struct IObjectInQueue;
+
+struct IObjectInQueue;
class TThreadFactoryHolder;
-
-using TThreadFunction = std::function<void()>;
-
+
+using TThreadFunction = std::function<void()>;
+
class IThreadPool;
class TFakeThreadPool;
class TThreadPool;
class TAdaptiveThreadPool;
class TSimpleThreadPool;
-
-template <class TQueueType, class TSlave>
+
+template <class TQueueType, class TSlave>
class TThreadPoolBinder;
diff --git a/util/thread/lfqueue.h b/util/thread/lfqueue.h
index 116e1d4c85..ab523631e4 100644
--- a/util/thread/lfqueue.h
+++ b/util/thread/lfqueue.h
@@ -1,7 +1,7 @@
#pragma once
-#include "fwd.h"
-
+#include "fwd.h"
+
#include <util/generic/ptr.h>
#include <util/system/atomic.h>
#include <util/system/yassert.h>
@@ -23,8 +23,8 @@ struct TDefaultLFCounter {
// @tparam TCounter, a observer class to count number of items in queue
// be carifull, IncCount and DecCount can be called on a moved object and
// it is TCounter class responsibility to check validity of passed object
-template <class T, class TCounter>
-class TLockFreeQueue: public TNonCopyable {
+template <class T, class TCounter>
+class TLockFreeQueue: public TNonCopyable {
struct TListNode {
template <typename U>
TListNode(U&& u, TListNode* next)
@@ -51,10 +51,10 @@ class TLockFreeQueue: public TNonCopyable {
TRootNode* volatile NextFree;
TRootNode()
- : PushQueue(nullptr)
- , PopQueue(nullptr)
- , ToDelete(nullptr)
- , NextFree(nullptr)
+ : PushQueue(nullptr)
+ , PopQueue(nullptr)
+ , ToDelete(nullptr)
+ , NextFree(nullptr)
{
}
void CopyCounter(TRootNode* x) {
@@ -78,7 +78,7 @@ class TLockFreeQueue: public TNonCopyable {
void TryToFreeAsyncMemory() {
TAtomic keepCounter = AtomicAdd(FreeingTaskCounter, 0);
TRootNode* current = AtomicGet(FreePtr);
- if (current == nullptr)
+ if (current == nullptr)
return;
if (AtomicAdd(FreememCounter, 0) == 1) {
// we are the last thread, try to cleanup
@@ -86,7 +86,7 @@ class TLockFreeQueue: public TNonCopyable {
if (keepCounter != AtomicAdd(FreeingTaskCounter, 0)) {
return;
}
- if (AtomicCas(&FreePtr, (TRootNode*)nullptr, current)) {
+ if (AtomicCas(&FreePtr, (TRootNode*)nullptr, current)) {
// free list
while (current) {
TRootNode* p = AtomicGet(current->NextFree);
@@ -131,29 +131,29 @@ class TLockFreeQueue: public TNonCopyable {
TListNode* PrevFirst;
TListInvertor()
- : Copy(nullptr)
- , Tail(nullptr)
- , PrevFirst(nullptr)
+ : Copy(nullptr)
+ , Tail(nullptr)
+ , PrevFirst(nullptr)
{
}
~TListInvertor() {
EraseList(Copy);
}
void CopyWasUsed() {
- Copy = nullptr;
- Tail = nullptr;
- PrevFirst = nullptr;
+ Copy = nullptr;
+ Tail = nullptr;
+ PrevFirst = nullptr;
}
void DoCopy(TListNode* ptr) {
TListNode* newFirst = ptr;
- TListNode* newCopy = nullptr;
- TListNode* newTail = nullptr;
+ TListNode* newCopy = nullptr;
+ TListNode* newTail = nullptr;
while (ptr) {
if (ptr == PrevFirst) {
// short cut, we have copied this part already
AtomicSet(Tail->Next, newCopy);
newCopy = Copy;
- Copy = nullptr; // do not destroy prev try
+ Copy = nullptr; // do not destroy prev try
if (!newTail)
newTail = Tail; // tried to invert same list
break;
@@ -188,7 +188,7 @@ class TLockFreeQueue: public TNonCopyable {
}
if (AtomicCas(&JobQueue, newRoot, curRoot)) {
- AsyncUnref(curRoot, nullptr);
+ AsyncUnref(curRoot, nullptr);
break;
}
}
@@ -229,7 +229,7 @@ public:
: JobQueue(new TRootNode)
, FreememCounter(0)
, FreeingTaskCounter(0)
- , FreePtr(nullptr)
+ , FreePtr(nullptr)
{
}
~TLockFreeQueue() {
@@ -272,7 +272,7 @@ public:
EnqueueImpl(node, tail);
}
bool Dequeue(T* data) {
- TRootNode* newRoot = nullptr;
+ TRootNode* newRoot = nullptr;
TListInvertor listInvertor;
AsyncRef();
for (;;) {
@@ -310,7 +310,7 @@ public:
newRoot->CopyCounter(curRoot);
Y_ASSERT(AtomicGet(curRoot->PopQueue) == nullptr);
if (AtomicCas(&JobQueue, newRoot, curRoot)) {
- newRoot = nullptr;
+ newRoot = nullptr;
listInvertor.CopyWasUsed();
AsyncDel(curRoot, AtomicGet(curRoot->PushQueue));
} else {
@@ -359,7 +359,7 @@ public:
}
};
-template <class T, class TCounter>
+template <class T, class TCounter>
class TAutoLockFreeQueue {
public:
using TRef = THolder<T>;
@@ -372,7 +372,7 @@ public:
}
inline bool Dequeue(TRef* t) {
- T* res = nullptr;
+ T* res = nullptr;
if (Queue.Dequeue(&res)) {
t->Reset(res);
diff --git a/util/thread/lfqueue_ut.cpp b/util/thread/lfqueue_ut.cpp
index aa6b21afeb..83bca100cf 100644
--- a/util/thread/lfqueue_ut.cpp
+++ b/util/thread/lfqueue_ut.cpp
@@ -102,8 +102,8 @@ int TOperationsChecker::CopyCtor_ = 0;
int TOperationsChecker::MoveAssign_ = 0;
int TOperationsChecker::CopyAssign_ = 0;
-Y_UNIT_TEST_SUITE(TLockFreeQueueTests) {
- Y_UNIT_TEST(TestMoveEnqueue) {
+Y_UNIT_TEST_SUITE(TLockFreeQueueTests) {
+ Y_UNIT_TEST(TestMoveEnqueue) {
TMoveTest value(0xFF, 0xAA);
TMoveTest tmp;
@@ -121,7 +121,7 @@ Y_UNIT_TEST_SUITE(TLockFreeQueueTests) {
UNIT_ASSERT_VALUES_EQUAL(tmp.Value(), 0xAA);
}
- Y_UNIT_TEST(TestSimpleEnqueueDequeue) {
+ Y_UNIT_TEST(TestSimpleEnqueueDequeue) {
TLockFreeQueue<int> queue;
int i = -1;
@@ -153,7 +153,7 @@ Y_UNIT_TEST_SUITE(TLockFreeQueueTests) {
UNIT_ASSERT_VALUES_EQUAL(i, tmp);
}
- Y_UNIT_TEST(TestSimpleEnqueueAllDequeue) {
+ Y_UNIT_TEST(TestSimpleEnqueueAllDequeue) {
TLockFreeQueue<int> queue;
int i = -1;
@@ -302,7 +302,7 @@ Y_UNIT_TEST_SUITE(TLockFreeQueueTests) {
UNIT_ASSERT_VALUES_EQUAL(v[2], 3);
}
- Y_UNIT_TEST(CleanInDestructor) {
+ Y_UNIT_TEST(CleanInDestructor) {
TSimpleSharedPtr<bool> p(new bool);
UNIT_ASSERT_VALUES_EQUAL(1u, p.RefCount());
@@ -318,7 +318,7 @@ Y_UNIT_TEST_SUITE(TLockFreeQueueTests) {
UNIT_ASSERT_VALUES_EQUAL(1, p.RefCount());
}
- Y_UNIT_TEST(CheckOperationsCount) {
+ Y_UNIT_TEST(CheckOperationsCount) {
TOperationsChecker o;
o.Check(1, 0, 0, 0, 0);
TLockFreeQueue<TOperationsChecker> queue;
diff --git a/util/thread/lfstack.h b/util/thread/lfstack.h
index bfdb9f6879..ca3d95f3c3 100644
--- a/util/thread/lfstack.h
+++ b/util/thread/lfstack.h
@@ -16,7 +16,7 @@ class TLockFreeStack: TNonCopyable {
template <class U>
explicit TNode(U&& val)
: Value(std::forward<U>(val))
- , Next(nullptr)
+ , Next(nullptr)
{
}
};
@@ -31,7 +31,7 @@ class TLockFreeStack: TNonCopyable {
return;
if (AtomicAdd(DequeueCount, 0) == 1) {
// node current is in free list, we are the last thread so try to cleanup
- if (AtomicCas(&FreePtr, (TNode*)nullptr, current))
+ if (AtomicCas(&FreePtr, (TNode*)nullptr, current))
EraseList(current);
}
}
@@ -57,8 +57,8 @@ class TLockFreeStack: TNonCopyable {
public:
TLockFreeStack()
- : Head(nullptr)
- , FreePtr(nullptr)
+ : Head(nullptr)
+ , FreePtr(nullptr)
, DequeueCount(0)
{
}
@@ -127,7 +127,7 @@ public:
void DequeueAll(TCollection* res) {
AtomicAdd(DequeueCount, 1);
for (TNode* current = AtomicGet(Head); current; current = AtomicGet(Head)) {
- if (AtomicCas(&Head, (TNode*)nullptr, current)) {
+ if (AtomicCas(&Head, (TNode*)nullptr, current)) {
for (TNode* x = current; x;) {
res->push_back(std::move(x->Value));
x = x->Next;
@@ -171,7 +171,7 @@ public:
template <typename TCollection>
void DequeueAllSingleConsumer(TCollection* res) {
for (TNode* current = AtomicGet(Head); current; current = AtomicGet(Head)) {
- if (AtomicCas(&Head, (TNode*)nullptr, current)) {
+ if (AtomicCas(&Head, (TNode*)nullptr, current)) {
for (TNode* x = current; x;) {
res->push_back(std::move(x->Value));
x = x->Next;
@@ -182,7 +182,7 @@ public:
}
}
bool IsEmpty() {
- AtomicAdd(DequeueCount, 0); // mem barrier
+ AtomicAdd(DequeueCount, 0); // mem barrier
return AtomicGet(Head) == nullptr; // without lock, so result is approximate
}
};
diff --git a/util/thread/lfstack_ut.cpp b/util/thread/lfstack_ut.cpp
index 9021220e88..e20a838f95 100644
--- a/util/thread/lfstack_ut.cpp
+++ b/util/thread/lfstack_ut.cpp
@@ -8,7 +8,7 @@
#include "lfstack.h"
-Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
+Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
class TCountDownLatch {
private:
TAtomic Current_;
@@ -106,15 +106,15 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
}
};
- Y_UNIT_TEST(TestDequeueAll) {
+ Y_UNIT_TEST(TestDequeueAll) {
TDequeueAllTester<false>().Run();
}
- Y_UNIT_TEST(TestDequeueAllSingleConsumer) {
+ Y_UNIT_TEST(TestDequeueAllSingleConsumer) {
TDequeueAllTester<true>().Run();
}
- Y_UNIT_TEST(TestDequeueAllEmptyStack) {
+ Y_UNIT_TEST(TestDequeueAllEmptyStack) {
TLockFreeStack<int> stack;
TVector<int> r;
@@ -123,7 +123,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
UNIT_ASSERT(r.empty());
}
- Y_UNIT_TEST(TestDequeueAllReturnsInReverseOrder) {
+ Y_UNIT_TEST(TestDequeueAllReturnsInReverseOrder) {
TLockFreeStack<int> stack;
stack.Enqueue(17);
@@ -140,7 +140,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
UNIT_ASSERT_VALUES_EQUAL(17, r.at(2));
}
- Y_UNIT_TEST(TestEnqueueAll) {
+ Y_UNIT_TEST(TestEnqueueAll) {
TLockFreeStack<int> stack;
TVector<int> v;
@@ -174,7 +174,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
}
}
- Y_UNIT_TEST(CleanInDestructor) {
+ Y_UNIT_TEST(CleanInDestructor) {
TSimpleSharedPtr<bool> p(new bool);
UNIT_ASSERT_VALUES_EQUAL(1u, p.RefCount());
@@ -307,7 +307,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
};
// Test for catching thread sanitizer problems
- Y_UNIT_TEST(TestFreeList) {
+ Y_UNIT_TEST(TestFreeList) {
TMultiThreadTester<TFreeListTest>().Run();
}
diff --git a/util/thread/pool.cpp b/util/thread/pool.cpp
index f280a29f9c..05fad02e9b 100644
--- a/util/thread/pool.cpp
+++ b/util/thread/pool.cpp
@@ -13,7 +13,7 @@
#include <util/generic/singleton.h>
#include <util/generic/fastqueue.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/string/builder.h>
#include <util/system/event.h>
@@ -94,7 +94,7 @@ public:
}
TAtforkQueueRestarter::Get().UnregisterObject(this);
- Y_ASSERT(Tharr.empty());
+ Y_ASSERT(Tharr.empty());
}
inline bool Add(IObjectInQueue* obj) {
@@ -209,7 +209,7 @@ private:
}
while (true) {
- IObjectInQueue* job = nullptr;
+ IObjectInQueue* job = nullptr;
with_lock (QueueMutex) {
while (Queue.Empty() && !AtomicGet(ShouldTerminate)) {
@@ -309,7 +309,7 @@ private:
#if defined(_bionic_)
//no pthread_atfork on android libc
#elif defined(_unix_)
- pthread_atfork(nullptr, nullptr, ProcessChildAction);
+ pthread_atfork(nullptr, nullptr, ProcessChildAction);
#endif
}
};
@@ -395,7 +395,7 @@ public:
TTsr tsr(Impl_->Parent_);
IObjectInQueue* obj;
- while ((obj = Impl_->WaitForJob()) != nullptr) {
+ while ((obj = Impl_->WaitForJob()) != nullptr) {
if (Impl_->Catching) {
try {
try {
@@ -424,7 +424,7 @@ public:
, Namer(params)
, ThrCount_(0)
, AllDone_(false)
- , Obj_(nullptr)
+ , Obj_(nullptr)
, Free_(0)
, IdleTime_(TDuration::Max())
{
@@ -445,7 +445,7 @@ public:
inline void Add(IObjectInQueue* obj) {
with_lock (Mutex_) {
- while (Obj_ != nullptr) {
+ while (Obj_ != nullptr) {
CondFree_.Wait(Mutex_);
}
@@ -522,7 +522,7 @@ private:
}
IObjectInQueue* ret = Obj_;
- Obj_ = nullptr;
+ Obj_ = nullptr;
--Free_;
@@ -746,7 +746,7 @@ namespace {
void DoJoin() noexcept override {
if (Impl_) {
Impl_->WaitForComplete();
- Impl_ = nullptr;
+ Impl_ = nullptr;
}
}
diff --git a/util/thread/pool.h b/util/thread/pool.h
index d7d56651e8..d1ea3a67cb 100644
--- a/util/thread/pool.h
+++ b/util/thread/pool.h
@@ -1,6 +1,6 @@
#pragma once
-#include "fwd.h"
+#include "fwd.h"
#include "factory.h"
#include <util/system/yassert.h>
@@ -217,12 +217,12 @@ public:
* Created resource is passed to IObjectInQueue::Proccess function.
*/
virtual void* CreateThreadSpecificResource() {
- return nullptr;
+ return nullptr;
}
virtual void DestroyThreadSpecificResource(void* resource) {
- if (resource != nullptr) {
- Y_ASSERT(resource == nullptr);
+ if (resource != nullptr) {
+ Y_ASSERT(resource == nullptr);
}
}
diff --git a/util/thread/pool_ut.cpp b/util/thread/pool_ut.cpp
index 18f4549dc2..893770d0c4 100644
--- a/util/thread/pool_ut.cpp
+++ b/util/thread/pool_ut.cpp
@@ -2,7 +2,7 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/stream/output.h>
+#include <util/stream/output.h>
#include <util/random/fast.h>
#include <util/system/spinlock.h>
#include <util/system/thread.h>
@@ -113,7 +113,7 @@ Y_UNIT_TEST_SUITE(TThreadPoolTest) {
}
}
- Y_UNIT_TEST(TestAddAndOwn) {
+ Y_UNIT_TEST(TestAddAndOwn) {
TThreadPool q;
q.Start(2);
bool processed = false;
@@ -125,7 +125,7 @@ Y_UNIT_TEST_SUITE(TThreadPoolTest) {
UNIT_ASSERT_C(destructed, "Not destructed");
}
- Y_UNIT_TEST(TestAddFunc) {
+ Y_UNIT_TEST(TestAddFunc) {
TFailAddQueue queue;
bool added = queue.AddFunc(
[]() {} // Lambda, I call him 'Lambda'!
@@ -138,7 +138,7 @@ Y_UNIT_TEST_SUITE(TThreadPoolTest) {
UNIT_CHECK_GENERATED_EXCEPTION(queue.SafeAddFunc([] {}), TThreadPoolException);
}
- Y_UNIT_TEST(TestFunctionNotCopied) {
+ Y_UNIT_TEST(TestFunctionNotCopied) {
struct TFailOnCopy {
TFailOnCopy() {
}
diff --git a/util/thread/singleton.h b/util/thread/singleton.h
index 8d3bdda992..4a1e05aea0 100644
--- a/util/thread/singleton.h
+++ b/util/thread/singleton.h
@@ -12,10 +12,10 @@ namespace NPrivate {
}
static inline T* Get() {
-#if defined(Y_HAVE_FAST_POD_TLS)
+#if defined(Y_HAVE_FAST_POD_TLS)
Y_POD_STATIC_THREAD(T*) fast(nullptr);
- if (Y_UNLIKELY(!fast)) {
+ if (Y_UNLIKELY(!fast)) {
fast = GetSlow();
}
diff --git a/util/thread/singleton_ut.cpp b/util/thread/singleton_ut.cpp
index d4a31b36f1..164b1cc184 100644
--- a/util/thread/singleton_ut.cpp
+++ b/util/thread/singleton_ut.cpp
@@ -12,8 +12,8 @@ namespace {
};
}
-Y_UNIT_TEST_SUITE(Tls) {
- Y_UNIT_TEST(FastThread) {
+Y_UNIT_TEST_SUITE(Tls) {
+ Y_UNIT_TEST(FastThread) {
UNIT_ASSERT_VALUES_EQUAL(0, FastTlsSingleton<TFoo>()->i);
FastTlsSingleton<TFoo>()->i += 3;
UNIT_ASSERT_VALUES_EQUAL(3, FastTlsSingleton<TFoo>()->i);
diff --git a/util/ya.make b/util/ya.make
index bed6c57106..6ebe7e40cf 100644
--- a/util/ya.make
+++ b/util/ya.make
@@ -23,7 +23,7 @@ PEERDIR(
JOIN_SRCS(
all_datetime.cpp
datetime/base.cpp
- datetime/constants.cpp
+ datetime/constants.cpp
datetime/cputimer.cpp
datetime/systime.cpp
datetime/uptime.cpp
@@ -45,8 +45,8 @@ ENDIF()
# digest
JOIN_SRCS(
all_digest.cpp
- digest/fnv.cpp
- digest/multi.cpp
+ digest/fnv.cpp
+ digest/multi.cpp
digest/murmur.cpp
digest/numeric.cpp
digest/sequence.cpp
@@ -62,11 +62,11 @@ JOIN_SRCS(
# folder
JOIN_SRCS(
all_folder.cpp
- folder/dirut.cpp
- folder/filelist.cpp
+ folder/dirut.cpp
+ folder/filelist.cpp
folder/fts.cpp
folder/fwd.cpp
- folder/iterator.cpp
+ folder/iterator.cpp
folder/path.cpp
folder/pathsplit.cpp
folder/tempdir.cpp
@@ -84,25 +84,25 @@ JOIN_SRCS(
all_generic.cpp
generic/scope.cpp
generic/adaptor.cpp
- generic/algorithm.cpp
+ generic/algorithm.cpp
generic/array_ref.cpp
generic/array_size.cpp
generic/bitmap.cpp
generic/bitops.cpp
generic/bt_exception.cpp
- generic/buffer.cpp
+ generic/buffer.cpp
generic/cast.cpp
generic/deque.cpp
- generic/explicit_type.cpp
+ generic/explicit_type.cpp
generic/fastqueue.cpp
generic/flags.cpp
- generic/function.cpp
+ generic/function.cpp
generic/fwd.cpp
- generic/guid.cpp
- generic/hash.cpp
- generic/hash_primes.cpp
+ generic/guid.cpp
+ generic/hash.cpp
+ generic/hash_primes.cpp
generic/hash_set.cpp
- generic/hide_ptr.cpp
+ generic/hide_ptr.cpp
generic/intrlist.cpp
generic/is_in.cpp
generic/iterator.cpp
@@ -112,63 +112,63 @@ JOIN_SRCS(
generic/map.cpp
generic/mapfindptr.cpp
generic/maybe.cpp
- generic/mem_copy.cpp
+ generic/mem_copy.cpp
generic/noncopyable.cpp
generic/object_counter.cpp
generic/overloaded.cpp
- generic/ptr.cpp
+ generic/ptr.cpp
generic/queue.cpp
generic/refcount.cpp
generic/serialized_enum.cpp
generic/set.cpp
- generic/singleton.cpp
+ generic/singleton.cpp
generic/size_literals.cpp
generic/stack.cpp
generic/store_policy.cpp
- generic/strbuf.cpp
- generic/strfcpy.cpp
- generic/string.cpp
- generic/typelist.cpp
+ generic/strbuf.cpp
+ generic/strfcpy.cpp
+ generic/string.cpp
+ generic/typelist.cpp
generic/typetraits.cpp
- generic/utility.cpp
- generic/va_args.cpp
+ generic/utility.cpp
+ generic/va_args.cpp
generic/vector.cpp
- generic/xrange.cpp
- generic/yexception.cpp
+ generic/xrange.cpp
+ generic/yexception.cpp
generic/ylimits.cpp
- generic/ymath.cpp
+ generic/ymath.cpp
)
# memory
JOIN_SRCS(
all_memory.cpp
- memory/addstorage.cpp
- memory/alloc.cpp
+ memory/addstorage.cpp
+ memory/alloc.cpp
memory/blob.cpp
memory/mmapalloc.cpp
memory/pool.cpp
memory/segmented_string_pool.cpp
memory/segpool_alloc.cpp
memory/smallobj.cpp
- memory/tempbuf.cpp
+ memory/tempbuf.cpp
)
# network
JOIN_SRCS(
all_network.cpp
- network/address.cpp
- network/endpoint.cpp
+ network/address.cpp
+ network/endpoint.cpp
network/hostip.cpp
network/init.cpp
network/interface.cpp
network/iovec.cpp
network/ip.cpp
- network/nonblock.cpp
- network/pair.cpp
- network/poller.cpp
+ network/nonblock.cpp
+ network/pair.cpp
+ network/poller.cpp
network/pollerimpl.cpp
network/sock.cpp
- network/socket.cpp
+ network/socket.cpp
)
# random
@@ -176,12 +176,12 @@ JOIN_SRCS(
all_random.cpp
random/common_ops.cpp
random/easy.cpp
- random/entropy.cpp
+ random/entropy.cpp
random/fast.cpp
random/lcg_engine.cpp
random/mersenne32.cpp
random/mersenne64.cpp
- random/mersenne.cpp
+ random/mersenne.cpp
random/normal.cpp
random/shuffle.cpp
random/init_atfork.cpp
@@ -189,53 +189,53 @@ JOIN_SRCS(
JOIN_SRCS(
all_stream.cpp
- stream/aligned.cpp
+ stream/aligned.cpp
stream/buffer.cpp
stream/buffered.cpp
stream/debug.cpp
stream/direct_io.cpp
stream/file.cpp
- stream/format.cpp
- stream/fwd.cpp
+ stream/format.cpp
+ stream/fwd.cpp
stream/hex.cpp
- stream/holder.cpp
+ stream/holder.cpp
stream/input.cpp
- stream/labeled.cpp
+ stream/labeled.cpp
stream/length.cpp
stream/mem.cpp
stream/multi.cpp
stream/null.cpp
stream/output.cpp
stream/pipe.cpp
- stream/printf.cpp
+ stream/printf.cpp
stream/str.cpp
stream/tee.cpp
stream/tempbuf.cpp
stream/tokenizer.cpp
stream/trace.cpp
- stream/walk.cpp
- stream/zerocopy.cpp
+ stream/walk.cpp
+ stream/zerocopy.cpp
stream/zerocopy_output.cpp
- stream/zlib.cpp
+ stream/zlib.cpp
)
JOIN_SRCS(
all_string.cpp
- string/ascii.cpp
+ string/ascii.cpp
string/builder.cpp
- string/cstriter.cpp
+ string/cstriter.cpp
string/escape.cpp
string/hex.cpp
string/join.cpp
- string/printf.cpp
+ string/printf.cpp
string/reverse.cpp
- string/split.cpp
- string/strip.cpp
+ string/split.cpp
+ string/strip.cpp
string/strspn.cpp
string/subst.cpp
- string/type.cpp
- string/util.cpp
- string/vector.cpp
+ string/type.cpp
+ string/util.cpp
+ string/vector.cpp
)
IF (ARCH_ARM)
@@ -264,7 +264,7 @@ JOIN_SRCS(
system/execpath.cpp
system/fasttime.cpp
system/file.cpp
- system/file_lock.cpp
+ system/file_lock.cpp
system/filemap.cpp
system/flock.cpp
system/fs.cpp
@@ -282,15 +282,15 @@ ENDIF()
JOIN_SRCS(
all_system_2.cpp
- system/align.cpp
- system/atomic.cpp
- system/byteorder.cpp
- system/cpu_id.cpp
- system/fhandle.cpp
- system/guard.cpp
+ system/align.cpp
+ system/atomic.cpp
+ system/byteorder.cpp
+ system/cpu_id.cpp
+ system/fhandle.cpp
+ system/guard.cpp
system/interrupt_signals.cpp
system/madvise.cpp
- system/maxlen.cpp
+ system/maxlen.cpp
system/mem_info.cpp
system/mincore.cpp
system/mktemp.cpp
@@ -305,22 +305,22 @@ JOIN_SRCS(
system/rwlock.cpp
system/sanitizers.cpp
system/sem.cpp
- system/shellcommand.cpp
+ system/shellcommand.cpp
system/shmat.cpp
- system/sigset.cpp
- system/spinlock.cpp
+ system/sigset.cpp
+ system/spinlock.cpp
system/spin_wait.cpp
- system/src_location.cpp
- system/sys_alloc.cpp
+ system/src_location.cpp
+ system/sys_alloc.cpp
system/sysstat.cpp
system/tempfile.cpp
system/thread.cpp
system/tls.cpp
system/types.cpp
system/type_name.cpp
- system/unaligned_mem.cpp
+ system/unaligned_mem.cpp
system/user.cpp
- system/utime.cpp
+ system/utime.cpp
system/yassert.cpp
system/yield.cpp
)
@@ -373,9 +373,9 @@ ENDIF()
JOIN_SRCS(
all_thread.cpp
thread/factory.cpp
- thread/fwd.cpp
- thread/lfqueue.cpp
- thread/lfstack.cpp
+ thread/fwd.cpp
+ thread/lfqueue.cpp
+ thread/lfstack.cpp
thread/pool.cpp
thread/singleton.cpp
)
diff --git a/util/ysafeptr.cpp b/util/ysafeptr.cpp
index d19af156f0..96f2514067 100644
--- a/util/ysafeptr.cpp
+++ b/util/ysafeptr.cpp
@@ -2,10 +2,10 @@
#ifdef CHECK_YPTR2
Y_POD_THREAD(bool)
-IObjectBase::DisableThreadCheck;
+IObjectBase::DisableThreadCheck;
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////
-void IObjectBase::ReleaseObjComplete(int nMask) {
+void IObjectBase::ReleaseObjComplete(int nMask) {
if ((ObjData & 0x3fffffff) == 0 && RefData == 0) {
assert((ObjData & 0x40000000) == 0); // object not being invalidated
delete this;
@@ -24,7 +24,7 @@ void IObjectBase::ReleaseObjComplete(int nMask) {
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void IObjectBase::ReleaseRefComplete() {
+void IObjectBase::ReleaseRefComplete() {
assert(RefData == 0);
if ((ObjData & 0x3fffffff) == 0) {
assert((ObjData & 0x40000000) == 0); // object not being invalidated
diff --git a/util/ysafeptr.h b/util/ysafeptr.h
index f663e8b356..af7dfd4bed 100644
--- a/util/ysafeptr.h
+++ b/util/ysafeptr.h
@@ -27,15 +27,15 @@
struct IBinSaver;
-class IObjectBase {
+class IObjectBase {
private:
#ifdef CHECK_YPTR2
- static Y_POD_THREAD(bool) DisableThreadCheck;
+ static Y_POD_THREAD(bool) DisableThreadCheck;
void CheckThreadId() {
if (dwThreadId == 0)
dwThreadId = GetCurrentThreadId();
else
- Y_ASSERT(dwThreadId == GetCurrentThreadId() || DisableThreadCheck);
+ Y_ASSERT(dwThreadId == GetCurrentThreadId() || DisableThreadCheck);
}
void AddRef() {
CheckThreadId();
@@ -87,14 +87,14 @@ protected:
// function should clear contents of object, easy to implement via consequent calls to
// destructor and constructor, this function should not be called directly, use Clear()
virtual void DestroyContents() = 0;
- virtual ~IObjectBase() = default;
- inline void CopyValidFlag(const IObjectBase& a) {
+ virtual ~IObjectBase() = default;
+ inline void CopyValidFlag(const IObjectBase& a) {
ObjData &= 0x7fffffff;
ObjData |= a.ObjData & 0x80000000;
}
public:
- IObjectBase()
+ IObjectBase()
: ObjData(0)
, RefData(0)
{
@@ -103,7 +103,7 @@ public:
#endif
}
// do not copy refcount when copy object
- IObjectBase(const IObjectBase& a)
+ IObjectBase(const IObjectBase& a)
: ObjData(0)
, RefData(0)
{
@@ -112,7 +112,7 @@ public:
#endif
CopyValidFlag(a);
}
- IObjectBase& operator=(const IObjectBase& a) {
+ IObjectBase& operator=(const IObjectBase& a) {
CopyValidFlag(a);
return *this;
}
@@ -121,7 +121,7 @@ public:
DisableThreadCheck = !val;
}
void ResetThreadId() {
- Y_ASSERT(RefData == 0 && ObjData == 0); // can reset thread check only for ref free objects
+ Y_ASSERT(RefData == 0 && ObjData == 0); // can reset thread check only for ref free objects
dwThreadId = 0;
}
#else
@@ -152,41 +152,41 @@ public:
}
struct TRefO {
- void AddRef(IObjectBase* pObj) {
+ void AddRef(IObjectBase* pObj) {
pObj->AddObj(1);
}
- void DecRef(IObjectBase* pObj) {
+ void DecRef(IObjectBase* pObj) {
pObj->DecObj(1);
}
- void Release(IObjectBase* pObj) {
+ void Release(IObjectBase* pObj) {
pObj->ReleaseObj(1, 0x000fffff);
}
};
struct TRefM {
- void AddRef(IObjectBase* pObj) {
+ void AddRef(IObjectBase* pObj) {
pObj->AddObj(0x100000);
}
- void DecRef(IObjectBase* pObj) {
+ void DecRef(IObjectBase* pObj) {
pObj->DecObj(0x100000);
}
- void Release(IObjectBase* pObj) {
+ void Release(IObjectBase* pObj) {
pObj->ReleaseObj(0x100000, 0x3ff00000);
}
};
struct TRef {
- void AddRef(IObjectBase* pObj) {
+ void AddRef(IObjectBase* pObj) {
pObj->AddRef();
}
- void DecRef(IObjectBase* pObj) {
+ void DecRef(IObjectBase* pObj) {
pObj->DecRef();
}
- void Release(IObjectBase* pObj) {
+ void Release(IObjectBase* pObj) {
pObj->ReleaseRef();
}
};
- friend struct IObjectBase::TRef;
- friend struct IObjectBase::TRefO;
- friend struct IObjectBase::TRefM;
+ friend struct IObjectBase::TRef;
+ friend struct IObjectBase::TRefO;
+ friend struct IObjectBase::TRefM;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
// macro that helps to create neccessary members for proper operation of refcount system
@@ -196,7 +196,7 @@ public: \
virtual const char* GetClassName() const override { \
return #classname; \
} \
- static IObjectBase* NewSaveLoadNullItem() { \
+ static IObjectBase* NewSaveLoadNullItem() { \
return new classname(); \
} \
\
@@ -215,38 +215,38 @@ private:
Y_PRAGMA_DIAGNOSTIC_PUSH \
Y_PRAGMA_NO_UNUSED_FUNCTION \
template <> \
- IObjectBase* CastToObjectBaseImpl<classname>(classname * p, void*) { \
+ IObjectBase* CastToObjectBaseImpl<classname>(classname * p, void*) { \
return p; \
} \
template <> \
- classname* CastToUserObjectImpl<classname>(IObjectBase * p, classname*, void*) { \
+ classname* CastToUserObjectImpl<classname>(IObjectBase * p, classname*, void*) { \
return dynamic_cast<classname*>(p); \
} \
Y_PRAGMA_DIAGNOSTIC_POP
////////////////////////////////////////////////////////////////////////////////////////////////////
template <class TUserObj>
-IObjectBase* CastToObjectBaseImpl(TUserObj* p, void*);
+IObjectBase* CastToObjectBaseImpl(TUserObj* p, void*);
template <class TUserObj>
-IObjectBase* CastToObjectBaseImpl(TUserObj* p, IObjectBase*) {
+IObjectBase* CastToObjectBaseImpl(TUserObj* p, IObjectBase*) {
return p;
}
template <class TUserObj>
-TUserObj* CastToUserObjectImpl(IObjectBase* p, TUserObj*, void*);
+TUserObj* CastToUserObjectImpl(IObjectBase* p, TUserObj*, void*);
template <class TUserObj>
-TUserObj* CastToUserObjectImpl(IObjectBase* _p, TUserObj*, IObjectBase*) {
+TUserObj* CastToUserObjectImpl(IObjectBase* _p, TUserObj*, IObjectBase*) {
return dynamic_cast<TUserObj*>(_p);
}
template <class TUserObj>
-inline IObjectBase* CastToObjectBase(TUserObj* p) {
+inline IObjectBase* CastToObjectBase(TUserObj* p) {
return CastToObjectBaseImpl(p, p);
}
template <class TUserObj>
-inline const IObjectBase* CastToObjectBase(const TUserObj* p) {
+inline const IObjectBase* CastToObjectBase(const TUserObj* p) {
return p;
}
template <class TUserObj>
-inline TUserObj* CastToUserObject(IObjectBase* p, TUserObj* pu) {
+inline TUserObj* CastToUserObject(IObjectBase* p, TUserObj* pu) {
return CastToUserObjectImpl(p, pu, pu);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -333,7 +333,7 @@ public:
TUserObj* Get() const {
return ptr;
}
- IObjectBase* GetBarePtr() const {
+ IObjectBase* GetBarePtr() const {
return CastToObjectBase(ptr);
}
int operator&(IBinSaver& f);
@@ -378,9 +378,9 @@ inline bool IsValid(const TPtrBase<T, TRef>& p) {
} \
};
-BASIC_PTR_DECLARE(TPtr, IObjectBase::TRef)
-BASIC_PTR_DECLARE(TObj, IObjectBase::TRefO)
-BASIC_PTR_DECLARE(TMObj, IObjectBase::TRefM)
+BASIC_PTR_DECLARE(TPtr, IObjectBase::TRef)
+BASIC_PTR_DECLARE(TObj, IObjectBase::TRefO)
+BASIC_PTR_DECLARE(TMObj, IObjectBase::TRefM)
// misuse guard
template <class T>
inline bool IsValid(TObj<T>* p) {
@@ -395,7 +395,7 @@ inline bool IsValid(TMObj<T>* p) {
return p->YouHaveMadeMistake();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-// assumes base class is IObjectBase
+// assumes base class is IObjectBase
template <class T>
class TDynamicCast {
T* ptr;
diff --git a/util/ysaveload.cpp b/util/ysaveload.cpp
index f3f07595f6..1ae3acb01e 100644
--- a/util/ysaveload.cpp
+++ b/util/ysaveload.cpp
@@ -2,12 +2,12 @@
#include <util/generic/buffer.h>
-void TSerializer<TBuffer>::Save(IOutputStream* rh, const TBuffer& buf) {
+void TSerializer<TBuffer>::Save(IOutputStream* rh, const TBuffer& buf) {
::SaveSize(rh, buf.Size());
::SavePodArray(rh, buf.Data(), buf.Size());
}
-void TSerializer<TBuffer>::Load(IInputStream* rh, TBuffer& buf) {
+void TSerializer<TBuffer>::Load(IInputStream* rh, TBuffer& buf) {
const size_t s = ::LoadSize(rh);
buf.Resize(s);
::LoadPodArray(rh, buf.Data(), buf.Size());
diff --git a/util/ysaveload.h b/util/ysaveload.h
index 818ea11801..02efb4049b 100644
--- a/util/ysaveload.h
+++ b/util/ysaveload.h
@@ -6,8 +6,8 @@
#include <util/generic/yexception.h>
#include <util/generic/typetraits.h>
#include <util/generic/algorithm.h>
-#include <util/stream/output.h>
-#include <util/stream/input.h>
+#include <util/stream/output.h>
+#include <util/stream/input.h>
#ifndef __NVCC__
// cuda is compiled in C++14 mode at the time
@@ -32,25 +32,25 @@ struct TLoadEOF: public TSerializeException {
};
template <class T>
-static inline void Save(IOutputStream* out, const T& t);
+static inline void Save(IOutputStream* out, const T& t);
template <class T>
-static inline void SaveArray(IOutputStream* out, const T* t, size_t len);
+static inline void SaveArray(IOutputStream* out, const T* t, size_t len);
template <class T>
-static inline void Load(IInputStream* in, T& t);
+static inline void Load(IInputStream* in, T& t);
template <class T>
-static inline void LoadArray(IInputStream* in, T* t, size_t len);
+static inline void LoadArray(IInputStream* in, T* t, size_t len);
template <class T, class TStorage>
-static inline void Load(IInputStream* in, T& t, TStorage& pool);
+static inline void Load(IInputStream* in, T& t, TStorage& pool);
template <class T, class TStorage>
-static inline void LoadArray(IInputStream* in, T* t, size_t len, TStorage& pool);
+static inline void LoadArray(IInputStream* in, T* t, size_t len, TStorage& pool);
template <class T>
-static inline void SavePodType(IOutputStream* rh, const T& t) {
+static inline void SavePodType(IOutputStream* rh, const T& t) {
rh->Write(&t, sizeof(T));
}
@@ -60,7 +60,7 @@ namespace NPrivate {
}
template <class T>
-static inline void LoadPodType(IInputStream* rh, T& t) {
+static inline void LoadPodType(IInputStream* rh, T& t) {
const size_t res = rh->Load(&t, sizeof(T));
if (Y_UNLIKELY(res != sizeof(T))) {
@@ -69,12 +69,12 @@ static inline void LoadPodType(IInputStream* rh, T& t) {
}
template <class T>
-static inline void SavePodArray(IOutputStream* rh, const T* arr, size_t count) {
+static inline void SavePodArray(IOutputStream* rh, const T* arr, size_t count) {
rh->Write(arr, sizeof(T) * count);
}
template <class T>
-static inline void LoadPodArray(IInputStream* rh, T* arr, size_t count) {
+static inline void LoadPodArray(IInputStream* rh, T* arr, size_t count) {
const size_t len = sizeof(T) * count;
const size_t res = rh->Load(arr, len);
@@ -84,21 +84,21 @@ static inline void LoadPodArray(IInputStream* rh, T* arr, size_t count) {
}
template <class It>
-static inline void SaveIterRange(IOutputStream* rh, It b, It e) {
+static inline void SaveIterRange(IOutputStream* rh, It b, It e) {
while (b != e) {
::Save(rh, *b++);
}
}
template <class It>
-static inline void LoadIterRange(IInputStream* rh, It b, It e) {
+static inline void LoadIterRange(IInputStream* rh, It b, It e) {
while (b != e) {
::Load(rh, *b++);
}
}
template <class It, class TStorage>
-static inline void LoadIterRange(IInputStream* rh, It b, It e, TStorage& pool) {
+static inline void LoadIterRange(IInputStream* rh, It b, It e, TStorage& pool) {
while (b != e) {
::Load(rh, *b++, pool);
}
@@ -106,24 +106,24 @@ static inline void LoadIterRange(IInputStream* rh, It b, It e, TStorage& pool) {
template <class T, bool isPod>
struct TSerializerTakingIntoAccountThePodType {
- static inline void Save(IOutputStream* out, const T& t) {
+ static inline void Save(IOutputStream* out, const T& t) {
::SavePodType(out, t);
}
- static inline void Load(IInputStream* in, T& t) {
+ static inline void Load(IInputStream* in, T& t) {
::LoadPodType(in, t);
}
template <class TStorage>
- static inline void Load(IInputStream* in, T& t, TStorage& /*pool*/) {
+ static inline void Load(IInputStream* in, T& t, TStorage& /*pool*/) {
::LoadPodType(in, t);
}
- static inline void SaveArray(IOutputStream* out, const T* t, size_t len) {
+ static inline void SaveArray(IOutputStream* out, const T* t, size_t len) {
::SavePodArray(out, t, len);
}
- static inline void LoadArray(IInputStream* in, T* t, size_t len) {
+ static inline void LoadArray(IInputStream* in, T* t, size_t len) {
::LoadPodArray(in, t, len);
}
};
@@ -137,97 +137,97 @@ struct TSerializerMethodSelector;
template <class T>
struct TSerializerMethodSelector<T, std::enable_if_t<NHasSaveLoad::THasSaveLoad<T>::value>> {
- static inline void Save(IOutputStream* out, const T& t) {
+ static inline void Save(IOutputStream* out, const T& t) {
//assume Save clause do not change t
(const_cast<T&>(t)).SaveLoad(out);
}
- static inline void Load(IInputStream* in, T& t) {
+ static inline void Load(IInputStream* in, T& t) {
t.SaveLoad(in);
}
template <class TStorage>
- static inline void Load(IInputStream* in, T& t, TStorage& pool) {
+ static inline void Load(IInputStream* in, T& t, TStorage& pool) {
t.SaveLoad(in, pool);
}
};
template <class T>
struct TSerializerMethodSelector<T, std::enable_if_t<!NHasSaveLoad::THasSaveLoad<T>::value>> {
- static inline void Save(IOutputStream* out, const T& t) {
+ static inline void Save(IOutputStream* out, const T& t) {
t.Save(out);
}
- static inline void Load(IInputStream* in, T& t) {
+ static inline void Load(IInputStream* in, T& t) {
t.Load(in);
}
template <class TStorage>
- static inline void Load(IInputStream* in, T& t, TStorage& pool) {
+ static inline void Load(IInputStream* in, T& t, TStorage& pool) {
t.Load(in, pool);
}
};
template <class T>
struct TSerializerTakingIntoAccountThePodType<T, false>: public TSerializerMethodSelector<T> {
- static inline void SaveArray(IOutputStream* out, const T* t, size_t len) {
+ static inline void SaveArray(IOutputStream* out, const T* t, size_t len) {
::SaveIterRange(out, t, t + len);
}
- static inline void LoadArray(IInputStream* in, T* t, size_t len) {
+ static inline void LoadArray(IInputStream* in, T* t, size_t len) {
::LoadIterRange(in, t, t + len);
}
template <class TStorage>
- static inline void LoadArray(IInputStream* in, T* t, size_t len, TStorage& pool) {
+ static inline void LoadArray(IInputStream* in, T* t, size_t len, TStorage& pool) {
::LoadIterRange(in, t, t + len, pool);
}
};
template <class It, bool isPtr>
struct TRangeSerialize {
- static inline void Save(IOutputStream* rh, It b, It e) {
+ static inline void Save(IOutputStream* rh, It b, It e) {
SaveArray(rh, b, e - b);
}
- static inline void Load(IInputStream* rh, It b, It e) {
+ static inline void Load(IInputStream* rh, It b, It e) {
LoadArray(rh, b, e - b);
}
template <class TStorage>
- static inline void Load(IInputStream* rh, It b, It e, TStorage& pool) {
+ static inline void Load(IInputStream* rh, It b, It e, TStorage& pool) {
LoadArray(rh, b, e - b, pool);
}
};
template <class It>
struct TRangeSerialize<It, false> {
- static inline void Save(IOutputStream* rh, It b, It e) {
+ static inline void Save(IOutputStream* rh, It b, It e) {
SaveIterRange(rh, b, e);
}
- static inline void Load(IInputStream* rh, It b, It e) {
+ static inline void Load(IInputStream* rh, It b, It e) {
LoadIterRange(rh, b, e);
}
template <class TStorage>
- static inline void Load(IInputStream* rh, It b, It e, TStorage& pool) {
+ static inline void Load(IInputStream* rh, It b, It e, TStorage& pool) {
LoadIterRange(rh, b, e, pool);
}
};
template <class It>
-static inline void SaveRange(IOutputStream* rh, It b, It e) {
+static inline void SaveRange(IOutputStream* rh, It b, It e) {
TRangeSerialize<It, std::is_pointer<It>::value>::Save(rh, b, e);
}
template <class It>
-static inline void LoadRange(IInputStream* rh, It b, It e) {
+static inline void LoadRange(IInputStream* rh, It b, It e) {
TRangeSerialize<It, std::is_pointer<It>::value>::Load(rh, b, e);
}
template <class It, class TStorage>
-static inline void LoadRange(IInputStream* rh, It b, It e, TStorage& pool) {
+static inline void LoadRange(IInputStream* rh, It b, It e, TStorage& pool) {
TRangeSerialize<It, std::is_pointer<It>::value>::Load(rh, b, e, pool);
}
@@ -240,36 +240,36 @@ class TArraySerializer: public TSerializerTakingIntoAccountThePodType<T, TSerial
};
template <class T>
-static inline void Save(IOutputStream* out, const T& t) {
+static inline void Save(IOutputStream* out, const T& t) {
TSerializer<T>::Save(out, t);
}
template <class T>
-static inline void SaveArray(IOutputStream* out, const T* t, size_t len) {
+static inline void SaveArray(IOutputStream* out, const T* t, size_t len) {
TArraySerializer<T>::SaveArray(out, t, len);
}
template <class T>
-static inline void Load(IInputStream* in, T& t) {
+static inline void Load(IInputStream* in, T& t) {
TSerializer<T>::Load(in, t);
}
template <class T>
-static inline void LoadArray(IInputStream* in, T* t, size_t len) {
+static inline void LoadArray(IInputStream* in, T* t, size_t len) {
TArraySerializer<T>::LoadArray(in, t, len);
}
template <class T, class TStorage>
-static inline void Load(IInputStream* in, T& t, TStorage& pool) {
+static inline void Load(IInputStream* in, T& t, TStorage& pool) {
TSerializer<T>::Load(in, t, pool);
}
template <class T, class TStorage>
-static inline void LoadArray(IInputStream* in, T* t, size_t len, TStorage& pool) {
+static inline void LoadArray(IInputStream* in, T* t, size_t len, TStorage& pool) {
TArraySerializer<T>::LoadArray(in, t, len, pool);
}
-static inline void SaveSize(IOutputStream* rh, size_t len) {
+static inline void SaveSize(IOutputStream* rh, size_t len) {
if ((ui64)len < 0xffffffff) {
::Save(rh, (ui32)len);
} else {
@@ -278,7 +278,7 @@ static inline void SaveSize(IOutputStream* rh, size_t len) {
}
}
-static inline size_t LoadSize(IInputStream* rh) {
+static inline size_t LoadSize(IInputStream* rh) {
ui32 oldVerSize;
ui64 newVerSize;
::Load(rh, oldVerSize);
@@ -291,7 +291,7 @@ static inline size_t LoadSize(IInputStream* rh) {
}
template <class C>
-static inline void LoadSizeAndResize(IInputStream* rh, C& c) {
+static inline void LoadSizeAndResize(IInputStream* rh, C& c) {
c.resize(LoadSize(rh));
}
@@ -303,14 +303,14 @@ static inline char* AllocateFromPool(TStorage& pool, size_t len) {
template <>
class TSerializer<const char*> {
public:
- static inline void Save(IOutputStream* rh, const char* s) {
+ static inline void Save(IOutputStream* rh, const char* s) {
size_t length = strlen(s);
::SaveSize(rh, length);
::SavePodArray(rh, s, length);
}
template <class Char, class TStorage>
- static inline void Load(IInputStream* rh, Char*& s, TStorage& pool) {
+ static inline void Load(IInputStream* rh, Char*& s, TStorage& pool) {
const size_t len = LoadSize(rh);
char* res = AllocateFromPool(pool, len + 1);
@@ -325,12 +325,12 @@ class TVectorSerializer {
using TIter = typename TVec::iterator;
public:
- static inline void Save(IOutputStream* rh, const TVec& v) {
+ static inline void Save(IOutputStream* rh, const TVec& v) {
::SaveSize(rh, v.size());
::SaveRange(rh, v.begin(), v.end());
}
- static inline void Load(IInputStream* rh, TVec& v) {
+ static inline void Load(IInputStream* rh, TVec& v) {
::LoadSizeAndResize(rh, v);
TIter b = v.begin();
TIter e = (TIter)v.end();
@@ -338,7 +338,7 @@ public:
}
template <class TStorage>
- static inline void Load(IInputStream* rh, TVec& v, TStorage& pool) {
+ static inline void Load(IInputStream* rh, TVec& v, TStorage& pool) {
::LoadSizeAndResize(rh, v);
TIter b = v.begin();
TIter e = (TIter)v.end();
@@ -385,11 +385,11 @@ class TSerializer<std::deque<T, A>>: public TVectorSerializer<std::deque<T, A>>
template <class TArray>
class TStdArraySerializer {
public:
- static inline void Save(IOutputStream* rh, const TArray& a) {
+ static inline void Save(IOutputStream* rh, const TArray& a) {
::SaveArray(rh, a.data(), a.size());
}
- static inline void Load(IInputStream* rh, TArray& a) {
+ static inline void Load(IInputStream* rh, TArray& a) {
::LoadArray(rh, a.data(), a.size());
}
};
@@ -403,18 +403,18 @@ class TSerializer<std::pair<A, B>> {
using TPair = std::pair<A, B>;
public:
- static inline void Save(IOutputStream* rh, const TPair& p) {
+ static inline void Save(IOutputStream* rh, const TPair& p) {
::Save(rh, p.first);
::Save(rh, p.second);
}
- static inline void Load(IInputStream* rh, TPair& p) {
+ static inline void Load(IInputStream* rh, TPair& p) {
::Load(rh, p.first);
::Load(rh, p.second);
}
template <class TStorage>
- static inline void Load(IInputStream* rh, TPair& p, TStorage& pool) {
+ static inline void Load(IInputStream* rh, TPair& p, TStorage& pool) {
::Load(rh, p.first, pool);
::Load(rh, p.second, pool);
}
@@ -449,8 +449,8 @@ struct TSerializer<std::tuple<TArgs...>>: TTupleSerializer<std::tuple<TArgs...>>
template <>
class TSerializer<TBuffer> {
public:
- static void Save(IOutputStream* rh, const TBuffer& buf);
- static void Load(IInputStream* rh, TBuffer& buf);
+ static void Save(IOutputStream* rh, const TBuffer& buf);
+ static void Load(IInputStream* rh, TBuffer& buf);
};
template <class TSetOrMap, class TValue>
@@ -471,26 +471,26 @@ protected:
};
template <class TSetOrMap, class TValue, bool sorted>
-class TSetSerializerInserter: public TSetSerializerInserterBase<TSetOrMap, TValue> {
+class TSetSerializerInserter: public TSetSerializerInserterBase<TSetOrMap, TValue> {
using TBase = TSetSerializerInserterBase<TSetOrMap, TValue>;
-
+
public:
inline TSetSerializerInserter(TSetOrMap& s, size_t cnt)
: TBase(s)
{
- Y_UNUSED(cnt);
+ Y_UNUSED(cnt);
}
};
template <class TSetType, class TValue>
class TSetSerializerInserter<TSetType, TValue, true>: public TSetSerializerInserterBase<TSetType, TValue> {
using TBase = TSetSerializerInserterBase<TSetType, TValue>;
-
+
public:
inline TSetSerializerInserter(TSetType& s, size_t cnt)
: TBase(s)
{
- Y_UNUSED(cnt);
+ Y_UNUSED(cnt);
P_ = this->S_.begin();
}
@@ -506,7 +506,7 @@ template <class T1, class T2, class T3, class T4, class T5, class TValue>
class TSetSerializerInserter<THashMap<T1, T2, T3, T4, T5>, TValue, false>: public TSetSerializerInserterBase<THashMap<T1, T2, T3, T4, T5>, TValue> {
using TMapType = THashMap<T1, T2, T3, T4, T5>;
using TBase = TSetSerializerInserterBase<TMapType, TValue>;
-
+
public:
inline TSetSerializerInserter(TMapType& m, size_t cnt)
: TBase(m)
@@ -532,7 +532,7 @@ template <class T1, class T2, class T3, class T4, class TValue>
class TSetSerializerInserter<THashSet<T1, T2, T3, T4>, TValue, false>: public TSetSerializerInserterBase<THashSet<T1, T2, T3, T4>, TValue> {
using TSetType = THashSet<T1, T2, T3, T4>;
using TBase = TSetSerializerInserterBase<TSetType, TValue>;
-
+
public:
inline TSetSerializerInserter(TSetType& s, size_t cnt)
: TBase(s)
@@ -684,12 +684,12 @@ private:
#endif
template <class T>
-static inline void SaveLoad(IOutputStream* out, const T& t) {
+static inline void SaveLoad(IOutputStream* out, const T& t) {
Save(out, t);
}
template <class T>
-static inline void SaveLoad(IInputStream* in, T& t) {
+static inline void SaveLoad(IInputStream* in, T& t) {
Load(in, t);
}
@@ -703,12 +703,12 @@ static inline void LoadMany(S* s, Ts&... t) {
ApplyToMany([&](auto& v) { Load(s, v); }, t...);
}
-#define Y_SAVELOAD_DEFINE(...) \
- inline void Save(IOutputStream* s) const { \
+#define Y_SAVELOAD_DEFINE(...) \
+ inline void Save(IOutputStream* s) const { \
::SaveMany(s, __VA_ARGS__); \
} \
\
- inline void Load(IInputStream* s) { \
+ inline void Load(IInputStream* s) { \
::LoadMany(s, __VA_ARGS__); \
}
diff --git a/util/ysaveload_ut.cpp b/util/ysaveload_ut.cpp
index 74935a9d25..723c68f391 100644
--- a/util/ysaveload_ut.cpp
+++ b/util/ysaveload_ut.cpp
@@ -34,11 +34,11 @@ class TSaveLoadTest: public TTestBase {
UNIT_TEST_SUITE_END();
struct TSaveHelper {
- inline void Save(IOutputStream* o) const {
+ inline void Save(IOutputStream* o) const {
o->Write("qwerty", 7);
}
- inline void Load(IInputStream* i) {
+ inline void Load(IInputStream* i) {
char buf[7];
UNIT_ASSERT_EQUAL(i->Load(buf, 7), 7);
@@ -59,7 +59,7 @@ class TSaveLoadTest: public TTestBase {
TString Str;
ui32 Int;
- Y_SAVELOAD_DEFINE(Str, Int)
+ Y_SAVELOAD_DEFINE(Str, Int)
};
private: