Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8674451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:42:47+00:00 2026-06-12T19:42:47+00:00

I am currently working on a small bash script that reads source C files

  • 0

I am currently working on a small bash script that reads source C files and then finds corresponding include files.

Now I have to choose between two models of finding a mapping M: filename -> {include file paths }. What I have are two arrays – one with found include filenames and another containing possible paths. The options are :

a) look for each file in one path, then proceed to another path;

b) look through a list of paths to find one file, then proceed to another file.

My question is – what will be faster? There is equal number of iterations in each of the choices, but maybe some of the commands are more time-consuming? I personally prefer option a).

Thanks for any help and sorry if this was a stupid question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:42:48+00:00Added an answer on June 12, 2026 at 7:42 pm

    There would be the same amount of iterations only if you coded it badly, not using the continue keyword once a match is found (don’t forget it can take a number as an argument to affect outer loops too).

    I would iterate through all the include files and look into the paths with some ordering – <system> includes should search system include paths first for quicker results, while the same holds true for "local" includes. It would be unwise to discard this information while parsing.

    However, I think you can do better by just running find -type f on all the include paths and storing the result in a temporary file or a variable. Then you would just grep (or any equivalent) it for the includes themselves. This way you save some I/O, since half of it is read in one go and only once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a small script that needs to use gtk.StatusIcon() . For
I have written a small bash* script to process files in a directory. The
I’m currently working on a small web app that allows people to search for
I'm currently working on a very small open source project for Maemo 5. (Namely
I'm currently working on a small 2D game-engine in C++, but I am now
we are currently working on a rails project that uses i18n and we have
I'm currently working on a small project where I'm loading 16bit wave files with
I'm currently working on a small cute shell script to loop through a specific
I am currently working on writing small game that is written in javascript, alot
I am new in android and currently working on small application that works on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.