-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
61 lines (45 loc) · 2.07 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
NAME
Sub::Disable - Remove function/method call from compiled code
SYNOPSIS
use Sub::Disable 'debug', 'foo', 'bar'; # without specification - both method + sub form calls
use Sub::Disable method => ['debug'];
use Sub::Disable sub => ['debug'];
use Sub::Disable {
method => ['foo'],
sub => ['bar'],
};
sub debug { warn "DEBUG INFO: @_" }
__PACKAGE__->debug(some_heave_debug()); # no-op
debug(even_more(), heavier_debug()); # no-op
DESCRIPTION
This module allows you to turn compile-time resolvable function or
method call into no-op (together with all arguments' computations). This
is useful for debugging and/or logging, when you don't want to make your
production code slower.
Note that 'compile-time resolvable method call' is a method call on a
literal package name
Some::Package->method
# or
__PACKAGE__->method
and does not consider inheritance.
Sub::Disable distinguishes between sub and method calls and, by default,
removes both of them. If you want to remove only one type, you should
use specific import.
PERFORMACE
There's zero runtime overhead. Compile time overhead is negligible - on
a test run it took an additional 0.2 ms during compilation of a
large-scale project with 1200+ modules loaded.
CAVEATS
Sub::Disable will remove only those sub/method calls that were compiled
after you have use'd it.
If you use Sub::Disable together with namespace::clean and you want to
remove sub call, but not a method call, of a specific function, you
should use Sub::Disable after using namespace::clean or exclude that
method with '-except'.
SEE ALSO
B::Hooks::OP::Check and various OP_check[] related core stuff.
COPYRIGHT AND LICENSE
Copyright (C) 2015 by Sergey Aleynikov
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself, either Perl version 5.10.1 or, at
your option, any later version of Perl 5 you may have available.