From 46986a4f02c6f9919bbd75981948b26782194527 Mon Sep 17 00:00:00 2001 From: Dennis Shen Date: Fri, 20 Sep 2024 13:15:56 +0000 Subject: [PATCH] aconfig: update cpp codegen Use access system call to check existence of a file to reduce the cost. Change-Id: Id64b419db81b2f8ac923b49f7293ee8a54aa78ca --- tools/aconfig/aconfig/templates/cpp_source_file.template | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/aconfig/aconfig/templates/cpp_source_file.template b/tools/aconfig/aconfig/templates/cpp_source_file.template index 623034a87b..852b905f32 100644 --- a/tools/aconfig/aconfig/templates/cpp_source_file.template +++ b/tools/aconfig/aconfig/templates/cpp_source_file.template @@ -2,7 +2,7 @@ {{ if allow_instrumentation }} {{ if readwrite- }} -#include +#include #include "aconfig_storage/aconfig_storage_read_api.hpp" #include #define LOG_TAG "aconfig_cpp_codegen" @@ -78,8 +78,7 @@ namespace {cpp_namespace} \{ , flag_value_file_(nullptr) , read_from_new_storage_(false) \{ - struct stat buffer; - if (stat("/metadata/aconfig/boot/enable_only_new_storage", &buffer) == 0) \{ + if (access("/metadata/aconfig/boot/enable_only_new_storage", F_OK) == 0) \{ read_from_new_storage_ = true; }