|
Title says it all.
Though the manual says you're better off to avoid a function call, I've also read $array[] is much slower than array_push(). Does anyone have any clarifications or benchmarks?
Thank you!
Started by alex on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
To add one element to the array it's better to use $array[] = because in that way.
|
|
Is it better in C++ to pass by value or pass by constant reference?
I am wondering which is better practice. I realize that pass by constant reference should provide for better performance in the program because you are not making a copy of the variable...
Started by Matt Pascoe on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
If a class is really....
Here is an example, assume you have.
For some basic types the performance in general the same both for passing, such as a pair of ints can perform better by passing by value.
better use passing by value.
|
|
If you are doing something like the following:
var i = $('input[@name=some_field]'); if (i.val() != '' && !(i.val() >=1 && i.val() <= 36) || i.val() == 'OT')) { i.focus(); }
is i.val() fast enough to use it multiple times or should you do:
var value...
Started by Darryl Hein on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
One thing to keep in mind is that if you store the value() will return a different value, especially if you are ....
DOM .value call as you incur the additional overhead of an extra function call as well what goes performance issues.
|
Ask your Facebook Friends
|
If we want to get a value from a method, we can use either return value, like this:
public int GetValue();
or:
public void GetValue(out int x);
I don't really understand the differences between them, and so, don't know which is better. Can you explain...
Started by Vimvq1987 on
, 12 posts
by 12 people.
Answer Snippets (Read the full thread at stackoverflow):
If you want to send a value in and out of the method, one would choose 'ref....
Public int Value' if they need to pass multiple values back from the method.
I would prefer the following instead of either of those in this simple example .
|
|
I came across this a few times in my career and never really found an answer. My question is in regards to a web form that contains multiple controls that the user can update, and then saves the data to a database (easiest example I can think of right...
Started by Rorschach on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
"save the individual control's value" - more optimized? I'd leave optimization than 6 separate ones
You may have....
"one method, stored procedure" - quicker to code, easier to maintain .
Depends what you mean by better.
Granularity of design.
|
|
I've been doing a massive code review and one pattern I notice all over the place is this:
public bool MethodName() { bool returnValue = false; if (expression) { // do something returnValue = MethodCall(); } else { // do something else returnValue = Expression...
Started by Omar Kooheji on
, 14 posts
by 14 people.
Answer Snippets (Read the full thread at stackoverflow):
I use this, too the return value is assigned now it does not mean that some code will not have to be added later memory or state before returning ....
Whether it's better or not is subjective.
And books advocate the single return practice.
|
|
I created a class that had one member of type List. I could then add to this using ClassNameInstance.Add() .
We are now using some code from a third-party that will automatically use any class I create and its values. Except lists. It only returns the...
Started by neildeadman on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
You should be able probably make the string value visible to the 3rd party code
public class MyClass", LastName = "Jordon" }, new Person() { FirstName = "Larry", LastName....
Have a return value, so the 3rd party code must be reading properties.
|
|
I'm currently using this code fragment to retrieve the one xml value that will be returned from my scalar query.
using (SqlDataReader reader = sqlCommand.ExecuteReader()) { while (reader.Read()) { SqlXml xml = reader.GetSqlXml(0); XmlSchema xmlSchema ...
Started by Ralph Shillington on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Obtain the XML as a string using the GetValue method or Value property.
Except for ExecuteScalar, you have 2 options on SqlDbType.Xml
An XML value.
The return value of the stored procedure).
|
|
If you want to associate some constant value with a class, here are two ways to accomplish the same goal:
class Foo { public: static const size_t Life = 42; }; class Bar { public: enum {Life = 42}; };
Syntactically and semantically they appear to be identical...
Started by John Dibling on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Modern compilers are also for not using the static const variant is if you want to forbid taking the address of the value: you can't take an address of an enum ....
Since this is no longer an issue, go for the other option .
Of the value.
|
|
Here's my code:
$quizId = ''; foreach ($module['QuizListing'] as $quizListing) { if ($quizListing['id']) { $quizId = $quizListing['id']; break; } }
Is there a better way of doing this?
Started by baker on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
If that's not the case then you can't get much better than what you're from a database you probably have to better to filter your query not to include those row at first.
Every quiz listing has an ID.
|