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 7923823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:26:28+00:00 2026-06-03T17:26:28+00:00

I have a peace of precedural code which is executed in a loop. This

  • 0

I have a peace of precedural code which is executed in a loop. This peace of code requires one large array, but only for reading and not manipulating purposes. I generate this array once before the loop.

Now I would like to move this code into a function in order to use it again is some other script, but I don’t know how to that in a clean way, but still having a good performance:

  • Generating this large array every time in the function itself would be bad, since it is always the same array and creates unnecessary overhead.
  • I dont want to use a global array, since this is bad practise
  • I guess therefore it would be the best to pass it as a paremeter every time I call the function.

I don’t like that last option too much either, because it clutters the argument list and I am not sure about the overhead caused through this. As I understand it the array would be copied every time – would it be a good idea to pass it by reference therefore (by using the & operator)?

  • 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-03T17:26:30+00:00Added an answer on June 3, 2026 at 5:26 pm

    One, who is really concerned in performance, should

    avoid processing large arrays in a performance-critical code.

    instead of playing tricks of speeding up an essentially slow process.

    So, without knowing a REAL CASE (the purpose, processing and content of the array) the only answer could be:

    Thus, turn your array into a database and select only necessary data.

    This is a general answer to such a general question like this.

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

Sidebar

Related Questions

I have this peace of code which brings string searches for img tags in
I have follwowing peace of code in which I have specified the leaky line
If I have this peace of code: <rich:select enableManualInput=true defaultLabel=Select time spent> <f:selectItems value=
Guys I have this peace of code I'm using phonegap with jqueryMobile to develop
I have a weirdest thing, in this peace of code a browser adds tags
peace folks, I have this small piece of jquery based code, that grabs all
I have this peace of code $doc = new DOMDocument(); $doc->loadHTML($article_header); $imgs = $doc->getElementsByTagName('img');
EDIT: This peace of code is pretty fine (so take it as example of
I'm creating a small game and I have a peace of code that collects
I have the following peace of code: <h:selectOneMenu id=countrycode styleClass=Width300 value=#{customer.countrycode} valueChangeListener=#{customer.countrycodechange} onchange=submit() immediate=true

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.