| |

VerySource

 Forgot password?
 Register
Search
View: 19|Reply: 9

Will nesting static functions inside static functions have an adverse effect?

[Copy link]

1

Threads

7

Posts

5

Credits

Newbie

Rank: 1

Credits
5

 China

Post time: 2020-3-5 09:00:02
| Show all posts |Read mode
class TestClass
{
    public static void FunA ()
    {
    }
    
    public static void FunB ()
    {
         TestClass.FunA ();
    }
}
For example, performance, concurrency?

Thank you
Reply

Use magic Report

0

Threads

89

Posts

51

Credits

Newbie

Rank: 1

Credits
51

 China

Post time: 2020-5-20 21:15:02
| Show all posts
It doesn't feel very good ..

Although I don't know the specific impact, it is recommended not to use it like this ..
Reply

Use magic Report

2

Threads

27

Posts

14

Credits

Newbie

Rank: 1

Credits
14

 China

Post time: 2020-5-23 03:15:01
| Show all posts
I don't think there is anything wrong, because the functions are in the code segment, and the member function and the static function are also poor.When compiling, the compiler will add the class const * this pointer to the member function, but it will take more time.
Reply

Use magic Report

0

Threads

13

Posts

11

Credits

Newbie

Rank: 1

Credits
11

 China

Post time: 2020-5-25 10:30:01
| Show all posts
Nothing bad, but faster
ls said very clearly
Reply

Use magic Report

0

Threads

89

Posts

51

Credits

Newbie

Rank: 1

Credits
51

 China

Post time: 2020-5-30 23:15:01
| Show all posts
TO: I don't think there is anything wrong, because the functions are all in the code segment, and the member function and the static function are also poor.When compiling, the compiler will add the class const * this pointer to the member function, but it will take more time.

As you mean, all member functions are made into static functions. Isn't that faster?

I am a beginner in C #, and I also express my opinion for reference only.
Reply

Use magic Report

0

Threads

89

Posts

51

Credits

Newbie

Rank: 1

Credits
51

 China

Post time: 2020-5-31 12:15:01
| Show all posts
Of course, the specific situation is also scored. Nothing is absolute, so it will definitely not go wrong in this way. In addition to having a certain impact on the packaging, what specific impact is there, I am not very clear ...

Comments are for reference only.
Reply

Use magic Report

0

Threads

13

Posts

11

Credits

Newbie

Rank: 1

Credits
11

 China

Post time: 2020-6-3 15:45:08
| Show all posts
"As you mean, all member functions can be made into static functions. Isn't that faster?"

It will be faster, but the static function is very troublesome to access the data of the object, because this cannot be used, hehe
How does calling static functions in static functions affect encapsulation?
Reply

Use magic Report

0

Threads

1

Posts

2

Credits

Newbie

Rank: 1

Credits
2

 China

Post time: 2020-6-7 05:30:01
| Show all posts
If FunA is being executed, is FunB.static variable called again?
Reply

Use magic Report

0

Threads

13

Posts

11

Credits

Newbie

Rank: 1

Credits
11

 China

Post time: 2020-6-8 10:45:01
| Show all posts
//If FunA is being executed, is FunB.static variable called again?

This multi-threaded problem, the lock variable will do.
What does it have to do with static functions? Ordinary functions will also encounter this problem in the case of multi-threading
Reply

Use magic Report

0

Threads

89

Posts

51

Credits

Newbie

Rank: 1

Credits
51

 China

Post time: 2020-6-30 02:00:01
| Show all posts
TO:lygzgs

Sorry, maybe my statement is wrong, hehe...

Regarding whether this usage is good or not, I just express my opinion, there is no absolute thing in everything, it depends on the specific situation.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list