-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate String comparison instead of HashMap for Router and use Meth…
…od data structure (#246) This makes the Router#route macro generate more efficient code. We now generate a direct string comparison for mapping the request to the right implementation, instead of a HashMap. An example macro expansion looks like this: ```scala val value = ApiImplFunResponse; val implRouter = sloth.Router.apply[test.PickleType, test.TypeHelper.ApiResultFun](TypeHelper.functor(SlothSpec.this.executionContext)); val impl = new _root_.sloth.internal.RouterImpl[test.PickleType, test.TypeHelper.ApiResultFun](implRouter); implRouter.orElse(((endpoint) => if (endpoint.traitName.$eq$eq("Api")) endpoint.methodName match { case "fun" => Some(((payload: test.PickleType) => impl.execute[scala.Tuple2[Int, String], Int](endpoint, payload)(((args) => value.fun(args._1, args._2))))) case "multi" => Some(((payload: test.PickleType) => impl.execute[scala.Tuple2[Int, Int], Int](endpoint, payload)(((args) => value.multi(args._1)(args._2))))) case _ => None } else None )) ``` We are also changing the reoccuring type `path: List[String]` to `Method`, which consists of the traitName and the methodName. We have added deprecated aliases for easier migration, it allows to work `List[String]` (now `Method`), `PathName` (now `Name`), `PathNotFound` (now `MethodNotFound`). These will be removed in the upcoming 1.0 release.
- Loading branch information
Showing
15 changed files
with
156 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.