Signed-off-by: Cao Xueliang caoxl78320@163.com --- src/scheduler/pp_params.cr | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/scheduler/pp_params.cr b/src/scheduler/pp_params.cr index da8d8f3..03bf0b8 100644 --- a/src/scheduler/pp_params.cr +++ b/src/scheduler/pp_params.cr @@ -50,10 +50,8 @@ class Job
private def format_string(original_str) temp = [] of String - original_str.each_char do |char| - if "#{char}" =~ /-|.|/|\w/ - temp << "#{char}".gsub("/", "-") - end + original_str.gsub('/', '-').each_char do |char| + temp << "#{char}" if "#{char}" =~ /\w|-|./ end
return temp.join()
It seems that this patch doesn't improve anything.
On Wed, Dec 02, 2020 at 04:23:38PM +0800, Cao Xueliang wrote:
Signed-off-by: Cao Xueliang caoxl78320@163.com
src/scheduler/pp_params.cr | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/scheduler/pp_params.cr b/src/scheduler/pp_params.cr index da8d8f3..03bf0b8 100644 --- a/src/scheduler/pp_params.cr +++ b/src/scheduler/pp_params.cr @@ -50,10 +50,8 @@ class Job
private def format_string(original_str) temp = [] of String
- original_str.each_char do |char|
if "#{char}" =~ /-|\.|\/|\w/
temp << "#{char}".gsub("\/", "-")
end
original_str.gsub('/', '-').each_char do |char|
temp << "#{char}" if "#{char}" =~ /\w|-|\./
end
return temp.join()
-- 2.23.0
On Wed, Dec 02, 2020 at 04:32:59PM +0800, Li Ping wrote:
It seems that this patch doesn't improve anything.
1. replace '/' at the first no need to replace every each. 2. put the "\w" at the first position regular.
Thanks, Xueliang
On Wed, Dec 02, 2020 at 04:23:38PM +0800, Cao Xueliang wrote:
Signed-off-by: Cao Xueliang caoxl78320@163.com
src/scheduler/pp_params.cr | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/scheduler/pp_params.cr b/src/scheduler/pp_params.cr index da8d8f3..03bf0b8 100644 --- a/src/scheduler/pp_params.cr +++ b/src/scheduler/pp_params.cr @@ -50,10 +50,8 @@ class Job
private def format_string(original_str) temp = [] of String
- original_str.each_char do |char|
if "#{char}" =~ /-|\.|\/|\w/
temp << "#{char}".gsub("\/", "-")
end
original_str.gsub('/', '-').each_char do |char|
temp << "#{char}" if "#{char}" =~ /\w|-|\./
end
return temp.join()
-- 2.23.0
On Wed, Dec 02, 2020 at 04:38:47PM +0800, Cao Xueliang wrote:
On Wed, Dec 02, 2020 at 04:32:59PM +0800, Li Ping wrote:
It seems that this patch doesn't improve anything.
- replace '/' at the first no need to replace every each.
- put the "\w" at the first position regular.
youe title should be optimize regular matching in format_string function, because you have not improve function. The function is essentially the same, you do it in a different way.
Thanks, Ping
Thanks, Xueliang
On Wed, Dec 02, 2020 at 04:23:38PM +0800, Cao Xueliang wrote:
Signed-off-by: Cao Xueliang caoxl78320@163.com
src/scheduler/pp_params.cr | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/scheduler/pp_params.cr b/src/scheduler/pp_params.cr index da8d8f3..03bf0b8 100644 --- a/src/scheduler/pp_params.cr +++ b/src/scheduler/pp_params.cr @@ -50,10 +50,8 @@ class Job
private def format_string(original_str) temp = [] of String
- original_str.each_char do |char|
if "#{char}" =~ /-|\.|\/|\w/
temp << "#{char}".gsub("\/", "-")
end
original_str.gsub('/', '-').each_char do |char|
temp << "#{char}" if "#{char}" =~ /\w|-|\./
end
return temp.join()
-- 2.23.0
On Wed, Dec 02, 2020 at 04:58:02PM +0800, Li Ping wrote:
On Wed, Dec 02, 2020 at 04:38:47PM +0800, Cao Xueliang wrote:
On Wed, Dec 02, 2020 at 04:32:59PM +0800, Li Ping wrote:
It seems that this patch doesn't improve anything.
- replace '/' at the first no need to replace every each.
- put the "\w" at the first position regular.
youe title should be optimize regular matching in format_string function, because you have not improve function. The function is essentially the same, you do it in a different way.
ok.
Thanks, Xueliang
Thanks, Ping
Thanks, Xueliang
On Wed, Dec 02, 2020 at 04:23:38PM +0800, Cao Xueliang wrote:
Signed-off-by: Cao Xueliang caoxl78320@163.com
src/scheduler/pp_params.cr | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/scheduler/pp_params.cr b/src/scheduler/pp_params.cr index da8d8f3..03bf0b8 100644 --- a/src/scheduler/pp_params.cr +++ b/src/scheduler/pp_params.cr @@ -50,10 +50,8 @@ class Job
private def format_string(original_str) temp = [] of String
- original_str.each_char do |char|
if "#{char}" =~ /-|\.|\/|\w/
temp << "#{char}".gsub("\/", "-")
end
original_str.gsub('/', '-').each_char do |char|
temp << "#{char}" if "#{char}" =~ /\w|-|\./
end
return temp.join()
-- 2.23.0