Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Global I18n Standard
提交
1f5f5162
G
Global I18n Standard
项目概览
OpenHarmony
/
Global I18n Standard
大约 1 年 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Global I18n Standard
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1f5f5162
编写于
3月 23, 2022
作者:
S
sunyaozu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix code quality problem
Signed-off-by:
N
sunyaozu
<
sunyaozu@huawei.com
>
上级
649f05a7
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
32 addition
and
25 deletion
+32
-25
frameworks/intl/include/i18n_break_iterator.h
frameworks/intl/include/i18n_break_iterator.h
+1
-1
frameworks/intl/include/i18n_calendar.h
frameworks/intl/include/i18n_calendar.h
+1
-1
frameworks/intl/include/index_util.h
frameworks/intl/include/index_util.h
+1
-1
frameworks/intl/include/locale_info.h
frameworks/intl/include/locale_info.h
+1
-1
frameworks/intl/include/number_format.h
frameworks/intl/include/number_format.h
+1
-0
frameworks/intl/src/number_format.cpp
frameworks/intl/src/number_format.cpp
+13
-7
frameworks/zone/test/unittest/zone_util_performance_test.cpp
frameworks/zone/test/unittest/zone_util_performance_test.cpp
+12
-12
interfaces/js/kits/src/i18n_addon.cpp
interfaces/js/kits/src/i18n_addon.cpp
+1
-1
interfaces/js/kits/src/intl_addon.cpp
interfaces/js/kits/src/intl_addon.cpp
+1
-1
未找到文件。
frameworks/intl/include/i18n_break_iterator.h
浏览文件 @
1f5f5162
...
...
@@ -22,7 +22,7 @@ namespace Global {
namespace
I18n
{
class
I18nBreakIterator
{
public:
I18nBreakIterator
(
std
::
string
lcoaleTag
);
explicit
I18nBreakIterator
(
std
::
string
lcoaleTag
);
virtual
~
I18nBreakIterator
();
int32_t
current
();
int32_t
first
();
...
...
frameworks/intl/include/i18n_calendar.h
浏览文件 @
1f5f5162
...
...
@@ -39,7 +39,7 @@ enum CalendarType {
class
I18nCalendar
{
public:
I18nCalendar
(
std
::
string
localeTag
);
explicit
I18nCalendar
(
std
::
string
localeTag
);
I18nCalendar
(
std
::
string
localeTag
,
CalendarType
type
);
virtual
~
I18nCalendar
();
void
SetTime
(
double
time
);
...
...
frameworks/intl/include/index_util.h
浏览文件 @
1f5f5162
...
...
@@ -24,7 +24,7 @@ namespace Global {
namespace
I18n
{
class
IndexUtil
{
public:
IndexUtil
(
const
std
::
string
&
localeTag
);
explicit
IndexUtil
(
const
std
::
string
&
localeTag
);
~
IndexUtil
();
std
::
vector
<
std
::
string
>
GetIndexList
();
void
AddLocale
(
const
std
::
string
&
localeTag
);
...
...
frameworks/intl/include/locale_info.h
浏览文件 @
1f5f5162
...
...
@@ -26,7 +26,7 @@ namespace Global {
namespace
I18n
{
class
LocaleInfo
{
public:
LocaleInfo
(
std
::
string
locale
);
explicit
LocaleInfo
(
std
::
string
locale
);
LocaleInfo
(
const
std
::
string
&
localeTag
,
std
::
map
<
std
::
string
,
std
::
string
>
&
configs
);
virtual
~
LocaleInfo
();
std
::
string
GetLanguage
()
const
;
...
...
frameworks/intl/include/number_format.h
浏览文件 @
1f5f5162
...
...
@@ -103,6 +103,7 @@ private:
void
GetDigitsResolvedOptions
(
std
::
map
<
std
::
string
,
std
::
string
>
&
map
);
void
InitProperties
();
void
InitDigitsProperties
();
void
SetUnit
(
std
::
string
&
preferredUnit
);
};
}
// namespace I18n
}
// namespace Global
...
...
frameworks/intl/src/number_format.cpp
浏览文件 @
1f5f5162
...
...
@@ -241,6 +241,18 @@ void NumberFormat::ParseDigitsConfigs(std::map<std::string, std::string> &config
}
}
void
NumberFormat
::
SetUnit
(
std
::
string
&
preferredUnit
)
{
if
(
preferredUnit
.
empty
())
{
return
;
}
for
(
icu
::
MeasureUnit
curUnit
:
unitArray
)
{
if
(
!
strcmp
(
curUnit
.
getSubtype
(),
preferredUnit
.
c_str
()))
{
numberFormat
=
numberFormat
.
unit
(
curUnit
);
}
}
}
std
::
string
NumberFormat
::
Format
(
double
number
)
{
double
finalNumber
=
number
;
...
...
@@ -273,13 +285,7 @@ std::string NumberFormat::Format(double number)
finalNumber
=
preferredValuesUnderOne
.
rbegin
()
->
first
;
preferredUnit
=
preferredValuesUnderOne
.
rbegin
()
->
second
;
}
if
(
!
preferredUnit
.
empty
())
{
for
(
icu
::
MeasureUnit
curUnit
:
unitArray
)
{
if
(
!
strcmp
(
curUnit
.
getSubtype
(),
preferredUnit
.
c_str
()))
{
numberFormat
=
numberFormat
.
unit
(
curUnit
);
}
}
}
SetUnit
(
preferredUnit
);
}
std
::
string
result
;
UErrorCode
status
=
U_ZERO_ERROR
;
...
...
frameworks/zone/test/unittest/zone_util_performance_test.cpp
浏览文件 @
1f5f5162
...
...
@@ -52,7 +52,7 @@ void ZoneUtilPerformanceTest::TearDown(void)
*/
HWTEST_F
(
ZoneUtilPerformanceTest
,
ZoneUtilPerformanceFuncTest001
,
TestSize
.
Level1
)
{
u
nsigned
long
long
total
=
0
;
u
int64_t
total
=
0
;
double
average
=
0
;
string
expects
[]
=
{
"Asia/Shanghai"
,
"America/New_York"
};
string
countries
[]
=
{
"JP"
,
"KR"
};
...
...
@@ -60,7 +60,7 @@ HWTEST_F(ZoneUtilPerformanceTest, ZoneUtilPerformanceFuncTest001, TestSize.Leve
ZoneUtil
util
;
for
(
int
k
=
0
;
k
<
1000
;
++
k
)
{
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
auto
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
auto
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
string
out
=
util
.
GetDefaultZone
(
countries
[
i
].
c_str
());
auto
t2
=
std
::
chrono
::
high_resolution_clock
::
now
();
total
+=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
t2
-
t1
).
count
();
...
...
@@ -77,7 +77,7 @@ HWTEST_F(ZoneUtilPerformanceTest, ZoneUtilPerformanceFuncTest001, TestSize.Leve
*/
HWTEST_F
(
ZoneUtilPerformanceTest
,
ZoneUtilPerformanceFuncTest002
,
TestSize
.
Level1
)
{
u
nsigned
long
long
total
=
0
;
u
int64_t
total
=
0
;
double
average
=
0
;
string
expects
[]
=
{
"Asia/Shanghai"
,
"America/Detroit"
};
int32_t
offsets
[]
=
{
3600
*
1000
*
8
,
-
3600
*
1000
*
5
};
...
...
@@ -86,7 +86,7 @@ HWTEST_F(ZoneUtilPerformanceTest, ZoneUtilPerformanceFuncTest002, TestSize.Leve
ZoneUtil
util
;
for
(
int
k
=
0
;
k
<
1000
;
++
k
)
{
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
auto
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
auto
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
string
out
=
util
.
GetDefaultZone
(
countries
[
i
].
c_str
(),
offsets
[
i
]);
auto
t2
=
std
::
chrono
::
high_resolution_clock
::
now
();
total
+=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
t2
-
t1
).
count
();
...
...
@@ -103,14 +103,14 @@ HWTEST_F(ZoneUtilPerformanceTest, ZoneUtilPerformanceFuncTest002, TestSize.Leve
*/
HWTEST_F
(
ZoneUtilPerformanceTest
,
ZoneUtilPerformanceFuncTest003
,
TestSize
.
Level1
)
{
u
nsigned
long
long
total
=
0
;
u
int64_t
total
=
0
;
double
average
=
0
;
vector
<
string
>
expects
=
{
"Asia/Shanghai"
,
"Asia/Urumqi"
};
string
country
=
"CN"
;
vector
<
string
>
out
;
ZoneUtil
util
;
for
(
int
k
=
0
;
k
<
1000
;
++
k
)
{
auto
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
auto
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
util
.
GetZoneList
(
country
,
out
);
auto
t2
=
std
::
chrono
::
high_resolution_clock
::
now
();
total
+=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
t2
-
t1
).
count
();
...
...
@@ -126,14 +126,14 @@ HWTEST_F(ZoneUtilPerformanceTest, ZoneUtilPerformanceFuncTest003, TestSize.Leve
*/
HWTEST_F
(
ZoneUtilPerformanceTest
,
ZoneUtilPerformanceFuncTest004
,
TestSize
.
Level1
)
{
u
nsigned
long
long
total
=
0
;
u
int64_t
total
=
0
;
double
average
=
0
;
vector
<
string
>
expects
=
{
"Europe/London"
};
string
country
=
"GB"
;
vector
<
string
>
out
;
ZoneUtil
util
;
for
(
int
k
=
0
;
k
<
1000
;
++
k
)
{
auto
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
auto
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
util
.
GetZoneList
(
country
,
out
);
auto
t2
=
std
::
chrono
::
high_resolution_clock
::
now
();
total
+=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
t2
-
t1
).
count
();
...
...
@@ -149,14 +149,14 @@ HWTEST_F(ZoneUtilPerformanceTest, ZoneUtilPerformanceFuncTest004, TestSize.Leve
*/
HWTEST_F
(
ZoneUtilPerformanceTest
,
ZoneUtilPerformanceFuncTest005
,
TestSize
.
Level1
)
{
u
nsigned
long
long
total
=
0
;
u
int64_t
total
=
0
;
double
average
=
0
;
vector
<
string
>
expects
=
{
"Europe/Berlin"
,
"Europe/Busingen"
};
string
country
=
"DE"
;
vector
<
string
>
out
;
ZoneUtil
util
;
for
(
int
k
=
0
;
k
<
1000
;
++
k
)
{
auto
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
auto
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
util
.
GetZoneList
(
country
,
out
);
auto
t2
=
std
::
chrono
::
high_resolution_clock
::
now
();
total
+=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
t2
-
t1
).
count
();
...
...
@@ -172,14 +172,14 @@ HWTEST_F(ZoneUtilPerformanceTest, ZoneUtilPerformanceFuncTest005, TestSize.Leve
*/
HWTEST_F
(
ZoneUtilPerformanceTest
,
ZoneUtilPerformanceFuncTest006
,
TestSize
.
Level1
)
{
u
nsigned
long
long
total
=
0
;
u
int64_t
total
=
0
;
double
average
=
0
;
vector
<
string
>
expects
=
{
"Asia/Shanghai"
};
string
country
=
"CN"
;
vector
<
string
>
out
;
ZoneUtil
util
;
for
(
int
k
=
0
;
k
<
1000
;
++
k
)
{
auto
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
auto
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
util
.
GetZoneList
(
country
,
3600
*
1000
*
8
,
out
);
auto
t2
=
std
::
chrono
::
high_resolution_clock
::
now
();
total
+=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
t2
-
t1
).
count
();
...
...
interfaces/js/kits/src/i18n_addon.cpp
浏览文件 @
1f5f5162
...
...
@@ -2701,7 +2701,7 @@ static napi_module g_i18nModule = {
.
nm_filename
=
nullptr
,
.
nm_register_func
=
Init
,
.
nm_modname
=
"i18n"
,
.
nm_priv
=
((
void
*
)
0
)
,
.
nm_priv
=
nullptr
,
.
reserved
=
{
0
}
};
...
...
interfaces/js/kits/src/intl_addon.cpp
浏览文件 @
1f5f5162
...
...
@@ -1982,7 +1982,7 @@ static napi_module g_intlModule = {
.
nm_filename
=
nullptr
,
.
nm_register_func
=
Init
,
.
nm_modname
=
"intl"
,
.
nm_priv
=
((
void
*
)
0
)
,
.
nm_priv
=
nullptr
,
.
reserved
=
{
0
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录