@@ -65,22 +65,16 @@ Pairs toPairs(std::string_view buffer) {
6565 if (buffer.size () < sizeof (uint32_t )) {
6666 return {};
6767 }
68- bool reverse = " null" != contextOrEffectiveContext ()->wasmVm ()->getEngineName ();
69- auto size = reverse ? wasmtoh (*reinterpret_cast <const uint32_t *>(b))
70- : *reinterpret_cast <const uint32_t *>(b);
68+ auto size = wasmtoh (*reinterpret_cast <const uint32_t *>(b));
7169 b += sizeof (uint32_t );
7270 if (sizeof (uint32_t ) + size * 2 * sizeof (uint32_t ) > buffer.size ()) {
7371 return {};
7472 }
7573 result.resize (size);
7674 for (uint32_t i = 0 ; i < size; i++) {
77- result[i].first =
78- std::string_view (nullptr , reverse ? wasmtoh (*reinterpret_cast <const uint32_t *>(b))
79- : *reinterpret_cast <const uint32_t *>(b));
75+ result[i].first = std::string_view (nullptr , wasmtoh (*reinterpret_cast <const uint32_t *>(b)));
8076 b += sizeof (uint32_t );
81- result[i].second =
82- std::string_view (nullptr , reverse ? wasmtoh (*reinterpret_cast <const uint32_t *>(b))
83- : *reinterpret_cast <const uint32_t *>(b));
77+ result[i].second = std::string_view (nullptr , wasmtoh (*reinterpret_cast <const uint32_t *>(b)));
8478 b += sizeof (uint32_t );
8579 }
8680 for (auto &p : result) {
@@ -697,7 +691,6 @@ Word wasi_unstable_fd_prestat_dir_name(Word /*fd*/, Word /*path_ptr*/, Word /*pa
697691// logs.
698692Word writevImpl (Word fd, Word iovs, Word iovs_len, Word *nwritten_ptr) {
699693 auto *context = contextOrEffectiveContext ();
700- bool reverse = " null" != context->wasmVm ()->getEngineName ();
701694
702695 // Read syscall args.
703696 uint64_t log_level;
@@ -721,9 +714,8 @@ Word writevImpl(Word fd, Word iovs, Word iovs_len, Word *nwritten_ptr) {
721714 }
722715 const auto *iovec = reinterpret_cast <const uint32_t *>(memslice.value ().data ());
723716 if (iovec[1 ] != 0U /* buf_len */ ) {
724- auto iovec0 = reverse ? wasmtoh (iovec[0 ]) : iovec[0 ];
725- auto iovec1 = reverse ? wasmtoh (iovec[1 ]) : iovec[1 ];
726- memslice = context->wasmVm ()->getMemory (iovec0 /* buf */ , iovec1 /* buf_len */ );
717+ memslice = context->wasmVm ()->getMemory (wasmtoh (iovec[0 ]) /* buf */ ,
718+ wasmtoh (iovec[1 ]) /* buf_len */ );
727719 if (!memslice) {
728720 return 21 ; // __WASI_EFAULT
729721 }
0 commit comments