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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:06:19+00:00 2026-05-12T16:06:19+00:00

I’m currently working on a performance critical application which incorporates legacy c code (a

  • 0

I’m currently working on a performance critical application which incorporates
legacy c code (a SPICE variant).

The problem is as follows:

The creators of the legacy c code apparently believed that the use of
argument passing is one of the great evils of the modern age. Thus about 90%
of all the variables were declared globally.

The legacy code has to be called repeatedly for simulation purposes and it would be seam that using threads for concurrent calls to this code section would be beneficial for the overall execution time.

My idea was to encapsulate the legacy c code (which I already modified slightly for g++ compilation) so that multiple objects for the legacy code can be created removing the necessity of to many mutex locks. Obviously the global variables will thus be encapsulated as member variables.

This brought another problem to the table. The legacy coders also did not believe in the initialization of global variables; probably since C tend to init global variables to 0.
C++ member variables does not seam to get the same treatment though. A few variables has to be initialized to 0 for the correct operation of the legacy c code. But finding these variables have proven to be quite difficult due to the vast amount of global variables used.

Please keep in mind that time does not permit me to modify the legacy c code to any major
degree.

My questions are as follows:

  1. Am I correct in the assumption that the encapsulation of the C code would be faster
    than the use of about 90 mutex locks?

  2. Is there an easy way of finding uninitialized member variable use? (As I understand gcc can only do this for automatic variables). So that I can init only the critical variables?

  3. If not Question 2 … is there a fast and clean way to initialize all the member variables without using the normal constructor init method?

  4. Or (a long shot) is there a fast way of following program flow so that I might incorporate the argument passing myself?

Any help will be vastly appreciated.
N.B.

  • 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-12T16:06:19+00:00Added an answer on May 12, 2026 at 4:06 pm
    1. Yes. If you can put the state into objects to which you pass pointers around, it will be faster than locking, assuming you actually do use threads.
    2. No, it’s not easy to find out unitialized member variables. Essentially, that would require to perform whole-code analysis, which it typically can’t do (due to the existence of libraries)
    3. If you put all data in an old-style struct (i.e. no methods, no access declarations), you are allowed to memset() the entire struct to zero. This will cause initialization in the same way as global variables get initialized (which C does guarantee to initialize – to zero).
    4. If, by fast, you mean “automatic”, then the answer is probably “no”.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 213k
  • Answers 213k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I finally found out what the problem was. It seems… May 12, 2026 at 10:33 pm
  • Editorial Team
    Editorial Team added an answer Why don't you just wrap the text? Anyway, Swing components… May 12, 2026 at 10:33 pm
  • Editorial Team
    Editorial Team added an answer if I take the guts of the render() function out… May 12, 2026 at 10:33 pm

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I have a French site that I want to parse, but am running into

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.