Commit Graph

24 Commits

Author SHA1 Message Date
4b9a142a5d Import global functions and constants for enhanced performance
This is better for performance because these then don't need to be reevaluated every time they are called.

When encountering an unqualified function or constant reference, PHP will first try to locate a symbol in the current namespace by that name, and then fall back to the global namespace.
This short-circuits the check, which has substantial performance effects in some cases - in particular, ord(), chr() and strlen() show ~1500x faster calls when they are fully qualified.

However, this doesn't mean that PM is getting a massive amount faster. In real world terms, this translates to about 10-15% performance improvement.
But before anyone gets excited, you should know that the CodeOptimizer in the PreProcessor repo has been applying fully-qualified symbol optimizations to Jenkins builds for years, which is one of the reasons why Jenkins builds have better performance than home-built or source installations.
We're choosing to do this for the sake of future SafePHP integration and also to be able to get rid of the buggy CodeOptimizer, so that phar and source are more consistent.
2019-01-04 20:43:15 +00:00
9ed1b5ca7f Event: More detailed errors for non-cancellable events 2018-12-31 21:29:22 +00:00
ba68192206 Fixed bad event handlers (whose errors get caught) breaking recursion protection for future event calls
This was observed in a recent crashdump where a plugin triggered a recursion error, but the stack trace did not contain any sign of a recursive event call. I conclude that this must have been caused by previous event handlers triggering errors 50 times in order to make the recursion detection break, because the recursion detection did not decrement the counter in cases where an exception was thrown.
2018-10-14 11:07:16 +01:00
ab5aec6c30 Event: Remove unnecessary check from call() hot path
This check is completely unnecessary since handlers get unregistered when a plugin is disabled. Additionally, this is an extremely hot path and this change produces a modest 5% performance improvement to event calls.
2018-10-07 16:36:30 +01:00
6efef3bbc7 Move event calling functionality to Event->call() method
This is dependent on the changes made in b1e0f82cbf. This now makes it possible to call events without fetching a Server reference, allowing to eliminate a vast array of Server dependencies.
2018-10-05 16:55:37 +01:00
eb0276d459 Apply nullable and void typehints to events namespace 2018-06-11 13:49:16 +01:00
49fbbea7bf Implemented event handler inheritance, allow registering handlers for any valid event (#1792)
* Event handlers always handle subclass events. public static $handlerList no longer required.
* Removed $handlerList declarations
* HandlerList cleanup: Removed HandlerList->handlers and related bake methods
* Removed obsolete Event->getHandlers()
* EventPriority: Added fromString()
* PluginManager: throw exceptions on registering handlers with invalid priorities

This allows specifying a handler of `EntityDamageEvent` which will handle any instanceof it (as per current behaviour), AND also now allows specifying a handler specifically for `EntityDamageByEntityEvent`, which only handles `EntityDamageEvent`.

This was not previously possible due to limitations in the way handlers were registered.

Abstract events may not be handled unless they declare the `@allowHandle` PhpDoc tag.
2018-03-20 17:05:09 +00:00
ac5a91b67e Cleaned up bool comparison mess 2018-03-19 14:10:55 +00:00
2a7b736f18 Heap of bugfixes, cleanup and PHP 7 upgrades 2017-07-13 19:18:56 +01:00
6cd4d2c5a2 Added typehints and PhpDoc for events API
excluded blocks and entities events API to avoid merge conflicts
2017-07-05 16:42:06 +01:00
a365c831a8 Fixed some doc problems 2017-06-25 12:07:28 +01:00
51b0673b4b Bite the bullet and enable strict types on everything 2017-06-07 12:53:16 +01:00
f3ab45e7d5 Merged in 1.0.6 changes, added autogenerated data for 1.1.0.3 (doesn't work yet) and deliberately made the same merge error as Mojang 2017-04-14 13:00:43 +01:00
9004417456 Fixed file headers (#255) 2017-01-13 16:57:05 +00:00
175dd0efa6 PhpStorm inspections
Fixed some minor bugs and dropped some obsolete code

pocketmine\level\generator namespace is ignored in this commit
2016-12-14 21:49:35 +00:00
8601405a88 Fixed CPU leak 2014-10-31 21:07:00 +01:00
6e8e2a79dd Fixed Event name being null 2014-10-30 14:52:11 +01:00
289bc56b4b Blocks now save their bounding box, fixed entity block collision check 2014-10-29 15:43:23 +01:00
78f8d0280d Removed unused imports 2014-10-29 01:14:09 +01:00
350cee3d41 Added Event allocation pool, updated SPL with Class::onClassLoaded() 2014-10-28 10:47:40 +01:00
ebb844fa52 Removed unused code, fixed undefined variables 2014-10-11 22:22:51 +02:00
db7222976e Code cleanup 2014-08-21 17:26:41 +02:00
a0ac660d57 Throw exception when a plugin tries to change the cancel event of a non-Cancellable event 2014-06-18 19:36:32 +02:00
dd17652aca Fixed wrong paths 2014-04-01 05:06:12 +02:00