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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:34:56+00:00 2026-05-18T05:34:56+00:00

Consider this piece of code: class A { void methodX() { // snip (1

  • 0

Consider this piece of code:


class A {
  void methodX() {
  // snip (1 liner function)
  }
}

class B {
  void methodX() {
   // same -code
  }
}
 

Now other way i can go is, I have a class(AppManager) most of whose members are static, (from legacy code, don’t suggest me singleton ;))


class AppManager {
  public:
  static void methodX(){
   // same-code
  }
}

Which one should be preferred?
As both are inlined, there shouldn’t be a runtime difference, right?
Which form is more cleaner?

  • 1 1 Answer
  • 2 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-18T05:34:56+00:00Added an answer on May 18, 2026 at 5:34 am

    Now first of all, this is a concern so minuscule that you would never have to worry about it unless the functions are called thousands of times per frame (and you’re doing something where “frames” matter).

    Second, IF they are inlined, the code will be (hopefully) optimized so much that there is no sign whatsoever of the function being non-static. It would be identical.

    Even if they were not inlined, the difference would be minor. The ABI would put the “this” pointer into a register (or the stack), which it wouldn’t do in a static function, but again, the net result would be almost not measurable.

    Bottom line – write your code in the cleanest possible way. Performance is not a concern at this point.

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

Sidebar

Related Questions

Consider this piece of code: public abstract class Validator { protected Validator() { }
Consider this piece of code: #include <vector> #include <iostream> using namespace std; class Base
Consider this piece of code var crazy = function() { console.log(this); console.log(this.isCrazy); // wrong.
Consider this small piece of code from apscheduler.scheduler import Scheduler import time class First():
Consider the following piece of code: class foo { private function m() { echo
Let's consider this piece of code as our example: import java.awt.*; class Maze extends
consider this piece of scala swing code detail.reactions += { case ButtonClicked(but) => detail.contents
consider this baby simple piece of code pg.connect( { user: 'hhope', password: '...', port:
Consider this (rather pointless) javascript code: function make_closure() { var x = 123, y
Consider this piece of code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using

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.