IWETHEY v. 0.3.0 | TODO
1,095 registered users | 1 active user | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New I don't think it will affect speed
but you'll have an extra field per instance if you don't use static. I don't see any reason why not to use it.
New Yep, its a size issue.
Without static, you have an instance variable in every instance that all point to the same string (done by the compiler so that string literals that are equivalent are also indentical). So you pay for 1 object reference per instance of the enclosing class.

If you make it static, you have one object reference, period. So you might save 4 bytes per instance by using static and since its a constant (it *is* a constant, right?) its a more rational way to do things.

The only speed impact would be at object construction time, the cost of initializing the per instance reference to the string. This is likely negligible - I doubt you could measure it without creating 100k objects in a tight loop and measuring the difference.
The average hunter gatherer works 20 hours a week.
The average farmer works 40 hours a week.
The average programmer works 60 hours a week.
What the hell are we thinking?
Expand Edited by tuberculosis Aug. 21, 2007, 05:57:47 AM EDT
     Java String field optimization tips? - (dlevitt) - (33)
         Strings shouldn't matter. - (admin) - (9)
             JDBC PreparedStatements - (dlevitt) - (8)
                 Depends on the database - (admin)
                 But back to the main question... - (admin) - (6)
                     Yeeha, Scott - (wharris2) - (5)
                         Java profiling usually works pretty well - (admin) - (2)
                             I believe that, no links required - (wharris2)
                             Try: JProbe... -NT - (slugbug)
                         Oh I believe it - (drewk) - (1)
                             Kinda missing the point... - (admin)
         Real world experience - (Yendor) - (18)
             (The technical reason) - (wharris2) - (7)
                 The technical reason behind the technical reason - (admin) - (6)
                     I don't believe it - (ben_tilly) - (5)
                         That would help, but.... - (marlowe) - (1)
                             The scheme addresses those acceptably well - (ben_tilly)
                         Compile time only - (dlevitt) - (2)
                             Are you sure? - (marlowe)
                             Compile time concatenation - (ChrisR)
             Sounds like a shitty compiler. - (tuberculosis) - (9)
                 Wrong, syntactically - (wharris2) - (8)
                     Read it again - (tuberculosis) - (7)
                         But what about the general case? - (ben_tilly) - (6)
                             Re: But what about the general case? - (tuberculosis) - (5)
                                 (arguing) - (wharris2)
                                 I always get dubious... - (ben_tilly) - (3)
                                     Don't know why - (tuberculosis) - (2)
                                         Whacky overloading. Yes. -NT - (wharris2)
                                         That I will agree with - (ben_tilly)
         Depends - (ChrisR)
         I don't think it will affect speed - (Arkadiy) - (1)
             Yep, its a size issue. - (tuberculosis)
         Re: Java String field optimization tips? - (dshellman)

Finito, bay-bee...
57 ms