[Beignet] *** SPAM LEVEL 4.053 *** [PATCH 1/2] Use access() instead of fopen() to search for PCH

He Junyan junyan.he at inbox.com
Thu Jul 25 01:35:27 PDT 2013


OK, more efficient

On 07/25/2013 04:31 PM, Simon Richter wrote:
> Since all we want to do is find out whether the file exists and can be
> read, use the appropriate function.
>
> Signed-off-by: Simon Richter <Simon.Richter at hogyros.de>
> ---
>   backend/src/backend/program.cpp |    5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
> index 20bdcec..26c22f3 100644
> --- a/backend/src/backend/program.cpp
> +++ b/backend/src/backend/program.cpp
> @@ -37,6 +37,7 @@
>   #include <fstream>
>   #include <dlfcn.h>
>   #include <sstream>
> +#include <unistd.h>
>   
>   /* Not defined for LLVM 3.0 */
>   #if !defined(LLVM_VERSION_MAJOR)
> @@ -258,10 +259,8 @@ namespace gbe {
>         std::istringstream idirs(dirs);
>   
>         while (getline(idirs, pchHeaderName, ';')) {
> -        FILE *pchFile = fopen(pchHeaderName.c_str(), "r");
> -        if (pchFile != NULL) {
> +        if(access(pchHeaderName.c_str(), R_OK) == 0) {
>             usePCH = true;
> -          fclose(pchFile);
>             break;
>           }
>         }





More information about the Beignet mailing list