Questions tagged [inline-method]

20 questions
39
votes
8 answers

Inlining in Java

In C++ I can declare a method "inline" and the compiler is likely to inline it. As far as I understand there is no such keyword in Java. Inlining is done if the JVM decides to do so? Can I influence this decision somehow?
CL23
  • 746
  • 2
  • 7
  • 12
37
votes
3 answers

C++ template and inline

When I'm writing a simple (non-template) class, if the function implementation is provided "right in place", it's automatically treated as inline. class A { void InlinedFunction() { int a = 0; } // ^^^^ the same as 'inline void…
Yippie-Ki-Yay
  • 20,062
  • 23
  • 85
  • 143
31
votes
4 answers

Why can't c# use inline anonymous lambdas or delegates?

I hope I worded the title of my question appropriately. In c# I can use lambdas (as delegates), or the older delegate syntax to do this: Func fnHello = () => "hello"; Console.WriteLine(fnHello()); Func fnHello2 = delegate() { …
Samuel Meacham
  • 9,845
  • 7
  • 42
  • 50
15
votes
5 answers

Inline member functions in C++

ISO C++ says that the inline definition of member function in C++ is the same as declaring it with inline. This means that the function will be defined in every compilation unit the member function is used. However, if the function call cannot be…
EFraim
  • 11,975
  • 3
  • 42
  • 62
15
votes
3 answers

Can method inlining optimization cause race conditions?

As seen in this question: Raising C# events with an extension method - is it bad? I'm thinking of using this extension method to safely raise an event: public static void SafeRaise(this EventHandler handler, object sender, EventArgs e) { if…
Jeff Cyr
  • 4,586
  • 1
  • 24
  • 40
14
votes
3 answers

Are inline operators good?

Is there any difference between operators and other methods to make inline in C++? I have searched for it, but it is not a common question, as I see. Has anyone a strong reason to use it or avoid? Note: clearly, I mean inline operators when they are…
JalalJaberi
  • 1,905
  • 8
  • 21
  • 37
9
votes
3 answers

C# - How do I define an inline method Func as a parameter?

I've written a simple SessionItem management class to handle all those pesky null checks and insert a default value if none exists. Here is my GetItem method: public static T GetItem(string key, Func defaultValue) { if…
tags2k
  • 70,860
  • 30
  • 74
  • 105
7
votes
1 answer

If optimizations are enabled will the JIT always inline this method?

I am not expecting a definite yes or no. Any knowledge you might have I will consider as an answer. private String CalculateCharge(Nullable bill, Nullable rate) { return ((bill ?? 0.0m) * (rate ?? 0.0m)).ToString("C"); }
ChaosPandion
  • 73,399
  • 16
  • 113
  • 152
6
votes
8 answers

C Inline Functions and Memory Use

If I use inline functions, does the memory usage increase?
Naveen kumar
5
votes
3 answers

Usage of inline closures / function delegates in Actionscript

Why are inline closures so rarely used in Actionscript? They are very powerful and I think quite readable. I hardly ever see anyone using them so maybe I'm just looking at the wrong code. Google uses them in their Google Maps API for Flash samples,…
Simon
  • 523
  • 1
  • 14
  • 21
4
votes
1 answer

How does the Delphi 2009 compiler handle recursive inline methods?

Do "What's wrong with using inline functions" and "Can a recursive function be inline" apply to Delphi inline functions? Furthermore, does anyone know how recursive inline functions are handled in Delphi?
Peter Turner
  • 10,788
  • 9
  • 62
  • 106
3
votes
3 answers

C++ inline methods with same if statements

i'm writting handler for OpenGL texture and i'm thinking about safety and performance. Which level of optimization should remove marked if statements? struct Texture2D { GLuint ID; inline Texture2D(): ID(0) {}; inline explicit…
kravemir
  • 9,380
  • 15
  • 54
  • 99
2
votes
1 answer

inline functions in c++

here is a small question about inline functions in c++. At what stage of the compilation in C++ are the inline functions actually inlined at the call? how does that basically work. lets say if the compiler has decided that a particualr function has…
Vijay
  • 59,537
  • 86
  • 209
  • 308
2
votes
3 answers

inline methods and code readability in modern C++

Alright, so sometimes my "coding brain" skips a gear; once in a while you can hear the gears grind. (For instance, every once in a while I write class Foo : Bar {} before reminding myself that's not proper anymore -- and hasn't been in a long…
John Price
  • 536
  • 1
  • 5
  • 18
2
votes
3 answers

Inline functions in dotNet 3.0+ with C#?

I am looking for a trick in newer dotnets where I can use inline functions that return a string value. Here's what I have: var split = new[] { " " }; var words = SearchTextBox.Text.Trim().Split( split, …
Matt
  • 24,106
  • 61
  • 180
  • 291
1
2