Skip to content

Commit

Permalink
performance: make support for ScriptIgnoreAttribute optional
Browse files Browse the repository at this point in the history
  • Loading branch information
tjanczuk committed Mar 29, 2013
1 parent b857ca2 commit 1e81d94
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/clrfunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,23 @@ Handle<v8::Value> ClrFunc::MarshalCLRObjectToV8(System::Object^ netdata)

for each (PropertyInfo^ property in type->GetProperties(BindingFlags::GetProperty | BindingFlags::Public | BindingFlags::Instance))
{
if (property->IsDefined(System::Web::Script::Serialization::ScriptIgnoreAttribute::typeid, true))
if (enableScriptIgnoreAttribute)
{
continue;
}
if (property->IsDefined(System::Web::Script::Serialization::ScriptIgnoreAttribute::typeid, true))
{
continue;
}

System::Web::Script::Serialization::ScriptIgnoreAttribute^ attr =
(System::Web::Script::Serialization::ScriptIgnoreAttribute^)System::Attribute::GetCustomAttribute(
property,
System::Web::Script::Serialization::ScriptIgnoreAttribute::typeid,
true);
System::Web::Script::Serialization::ScriptIgnoreAttribute^ attr =
(System::Web::Script::Serialization::ScriptIgnoreAttribute^)System::Attribute::GetCustomAttribute(
property,
System::Web::Script::Serialization::ScriptIgnoreAttribute::typeid,
true);

if (attr != nullptr && attr->ApplyToOverrides)
{
continue;
if (attr != nullptr && attr->ApplyToOverrides)
{
continue;
}
}

MethodInfo^ getMethod = property->GetGetMethod();
Expand Down
2 changes: 2 additions & 0 deletions src/edge.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "edge.h"

BOOL debugMode;
BOOL enableScriptIgnoreAttribute;
Persistent<Function> bufferConstructor;

Handle<Value> initializeClrFunc(const v8::Arguments& args)
Expand All @@ -15,6 +16,7 @@ void init(Handle<Object> target)
bufferConstructor = Persistent<Function>::New(Handle<Function>::Cast(
Context::GetCurrent()->Global()->Get(String::New("Buffer"))));
debugMode = (0 < GetEnvironmentVariable("EDGE_DEBUG", NULL, 0));
enableScriptIgnoreAttribute = (0 < GetEnvironmentVariable("EDGE_ENABLE_SCRIPTIGNOREATTRIBUTE", NULL, 0));
NODE_SET_METHOD(target, "initializeClrFunc", initializeClrFunc);
}

Expand Down
1 change: 1 addition & 0 deletions src/edge.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ using namespace System::Web::Script::Serialization;
// Good explanation of native Buffers at
// http://sambro.is-super-awesome.com/2011/03/03/creating-a-proper-buffer-in-a-node-c-addon/
extern BOOL debugMode;
extern BOOL enableScriptIgnoreAttribute;
extern Persistent<Function> bufferConstructor;

Handle<v8::String> stringCLR2V8(System::String^ text);
Expand Down

0 comments on commit 1e81d94

Please sign in to comment.