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

  • SEARCH
  • Home
  • 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 6088177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:57:19+00:00 2026-05-23T11:57:19+00:00

I need high-performance iteration over transient arrays (on stack and/or in heap) which can

  • 0

I need high-performance iteration over transient arrays (on stack and/or in heap) which can store mixed types of data, including various types of pointers.

I thought of using unions to determine largest size of several supported array members.

is the following, the fastest (safe) architecture and solution?

union array_sizer {
    void *(* funcPtr)();
    void *dataPtr;
    struct {int i} *strPtr;
    int intVal;
    float floatVal;
}

// create an array of 10 item *pairs*.
union array_sizer *myArray = malloc(22 * sizeof(union array_sizer));

// fill up the (null-terminated) array 

// then, knowing that every *even* item is an int...
for(int i=0; myArray[i].intVal; i+=2){
    //(... do something in loop ...)
}

the array data will be created from functions which enforce data integrity, so the for loop can be pretty skimpy on error checking beyond null-termination.

  • 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-05-23T11:57:19+00:00Added an answer on May 23, 2026 at 11:57 am

    I would make a parallel ‘look up table’ which indexes into the original array to say what type it is. So make an enum representing the types and make that a corresponding array.

    However if you look at performance if you do it this way you will get page faulting and cache misses because likely the 2 arrays are going to be on different pages. So to get round this what you want to do is instead of a ‘struct of arrays’ make an ‘array of structs’. To do this create a struct which has 2 members : the enum type constant and the data itself. If you do this, when we fetch an index it will ensure the data and the corresponding type information will be on the same page.

    This would be my preferred method from a high level design point of view.

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

Sidebar

Related Questions

Can you recommend a high-performance, thread-safe and stable ORM for Python? The data I
I need a high performance framework in native C++ for SQL. I need it
I need ideas to implement a (really) high performance in-memory Database/Storage Mechanism in Java.
I need ideas to implement a (really) high performance in-memory Database/Storage Mechanism. In the
Some high risk data operations need to be logged. In this case, the high
I need to do alot of high-performance case-insensitive string comparisons and realized that my
I need to solve the following question which i can't get to work by
I would like to implement a high-traffic restful .NET 4.0 WCF service which can
tl;dr: I want a high-level introduction to Rails, which covers what I need to
Even if you are using Agile, you would need a high level architecture before

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.