fs/pstore: Optimization function ramoops_init_przs
PATCH 1/1 fs/pstore: Optimization function ramoops_init_przs
The value of cxt->record_size does not change in the loop, so this patch optimize the assign statement by moving it to outer.
--- fs/pstore/ram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/pstore/ram.c +2 -2
@@ -373,6 +373,7 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, {int err = -ENOMEM ;int i; +size_t sz;if (!cxt->record_size)return 0 ;
@@ -393,9 +394,8 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, goto fail_prz; } + sz = cxt->record_size;for (i =0 ; i < cxt->max_dump_cnt; i++) { -size_t sz = cxt->record_size; - cxt->przs[i] =persistent_ram_new (*paddr, sz,0 , &cxt->ecc_info, cxt->memtype);
Signature · 1 line
1.8.3.4
Quoted 33 lines · Wang Long
The value of
cxt->record_sizedoes not change in the loop, so this patch optimize the assign statement by moving it to outer.Signed-off-by Wang Long <[email protected]>--- fs/pstore/ram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/pstore/ram.c +2
-3@@ -373,6 +373,7 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, {int err = -ENOMEM ;int i; +size_t sz;if (!cxt->record_size)return 0 ;@@ -393,9 +394,8 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, goto fail_prz; } + sz = cxt->record_size;for (i =0 ; i < cxt->max_dump_cnt; i++) { -size_t sz = cxt->record_size; - cxt->przs[i] =persistent_ram_new (*paddr, sz,0 , &cxt->ecc_info, cxt->memtype); --
Quoted 2 lines
1.8.3.4
Actually, can't we drop sz entirely and just use cxt->record_size in its place?
-Kees
Signature · 2 lines
Kees Cook Chrome OS Security
Quoted 39 lines · Kees Cook
Quoted 33 lines · Wang Long
The value of
cxt->record_sizedoes not change in the loop, so this patch optimize the assign statement by moving it to outer.Signed-off-by Wang Long <[email protected]>--- fs/pstore/ram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/pstore/ram.c +2
-3@@ -373,6 +373,7 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, {int err = -ENOMEM ;int i; +size_t sz;if (!cxt->record_size)return 0 ;@@ -393,9 +394,8 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, goto fail_prz; } + sz = cxt->record_size;for (i =0 ; i < cxt->max_dump_cnt; i++) { -size_t sz = cxt->record_size; - cxt->przs[i] =persistent_ram_new (*paddr, sz,0 , &cxt->ecc_info, cxt->memtype); --Quoted 2 lines
1.8.3.4
Actually, can't we drop sz entirely and just use
cxt->record_sizein its place?
Quoted 2 lines
-Kees
I agree with you.
drop sz entirely and use cxt->record_size in its place can improve readability.
I will send another patch.
Best Regards
Wang Long