Skip to content

Commit

Permalink
Use u16string_view instead of u16string
Browse files Browse the repository at this point in the history
  • Loading branch information
sgilmore10 committed Jul 7, 2023
1 parent ea4df1a commit e9cdc32
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
9 changes: 5 additions & 4 deletions matlab/src/cpp/arrow/matlab/array/proxy/timestamp_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ namespace arrow::matlab::array::proxy {
const mda::TypedArray<mda::MATLABString> units_mda = opts[0]["TimeUnit"];

// extract the time zone string
const std::u16string& u16_timezone = timezone_mda[0];
MATLAB_ASSIGN_OR_ERROR(const auto timezone, arrow::util::UTF16StringToUTF8(u16_timezone),
const std::u16string& utf16_timezone = timezone_mda[0];
MATLAB_ASSIGN_OR_ERROR(const auto timezone, arrow::util::UTF16StringToUTF8(utf16_timezone),
error::UNICODE_CONVERSION_ERROR_ID);

// extract the time unit
MATLAB_ASSIGN_OR_ERROR(const auto time_unit, arrow::matlab::type::timeUnitFromString(units_mda[0]),
error::UKNOWN_TIME_UNIT_ERROR_ID)
const std::u16string& utf16_unit = units_mda[0];
MATLAB_ASSIGN_OR_ERROR(const auto time_unit, arrow::matlab::type::timeUnitFromString(utf16_unit),
error::UKNOWN_TIME_UNIT_ERROR_ID);

// create the timestamp_type
auto data_type = arrow::timestamp(time_unit, timezone);
Expand Down
9 changes: 7 additions & 2 deletions matlab/src/cpp/arrow/matlab/type/proxy/timestamp_type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ namespace arrow::matlab::type::proxy {
const mda::StringArray timeunit_mda = opts[0]["TimeUnit"];

// extract the time zone
MATLAB_ASSIGN_OR_ERROR(const auto timezone, arrow::util::UTF16StringToUTF8(timezone_mda[0]),
const std::u16string& utf16_timezone = timezone_mda[0];
MATLAB_ASSIGN_OR_ERROR(const auto timezone,
arrow::util::UTF16StringToUTF8(utf16_timezone),
error::UNICODE_CONVERSION_ERROR_ID);

// extract the time unit
MATLAB_ASSIGN_OR_ERROR(const auto timeunit, arrow::matlab::type::timeUnitFromString(timeunit_mda[0]),
const std::u16string& utf16_timeunit = timeunit_mda[0];
MATLAB_ASSIGN_OR_ERROR(const auto timeunit,
arrow::matlab::type::timeUnitFromString(utf16_timeunit),
error::UKNOWN_TIME_UNIT_ERROR_ID);

auto type = arrow::timestamp(timeunit, timezone);
Expand Down
2 changes: 1 addition & 1 deletion matlab/src/cpp/arrow/matlab/type/time_unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace arrow::matlab::type {

arrow::Result<arrow::TimeUnit::type> timeUnitFromString(const std::u16string& unit_str) {
arrow::Result<arrow::TimeUnit::type> timeUnitFromString(std::u16string_view unit_str) {
if (unit_str == u"Second") {
return arrow::TimeUnit::type::SECOND;
} else if (unit_str == u"Millisecond") {
Expand Down
4 changes: 2 additions & 2 deletions matlab/src/cpp/arrow/matlab/type/time_unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#include "arrow/type_fwd.h"
#include "arrow/result.h"

#include <string>
#include <string_view>

namespace arrow::matlab::type {

arrow::Result<arrow::TimeUnit::type> timeUnitFromString(const std::u16string& unit_str);
arrow::Result<arrow::TimeUnit::type> timeUnitFromString(std::u16string_view unit_str);

}

0 comments on commit e9cdc32

Please sign in to comment.