You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2021/05/13 00:15:45 UTC

[GitHub] [trafficserver] SolidWallOfCode commented on a change in pull request #7818: Reduces an amount of conditional checks at the cache_op

SolidWallOfCode commented on a change in pull request #7818:
URL: https://github.com/apache/trafficserver/pull/7818#discussion_r631482577



##########
File path: iocore/aio/AIO.cc
##########
@@ -379,18 +379,15 @@ aio_queue_req(AIOCallbackInternal *op, int fromAPI = 0)
 static inline int
 cache_op(AIOCallbackInternal *op)
 {
-  bool read = (op->aiocb.aio_lio_opcode == LIO_READ);
+  typedef ssize_t (*p)(int, void*, size_t, __off_t);

Review comment:
       No new `typedef` usage allowed. `using` is the new standard (see [here](https://en.cppreference.com/w/cpp/language/using_declaration)). E.g.
   ```
   using p = ssize_t(int, void*, size_t, __off_t);
   ```
   Even better, though, would using `decltype` and a name more descriptive than "p". Because the point of the cast isn't obvious, a comment is useful. This uses `reinterpret_cast` because we no longer allow C style casts.
   ```
     using ActionFunc = decltype(&pread);
     // Need to cast @c pwrite because it takes a const void * vs. a void * for @c pread.
     auto action = op->aiocb.aio_lio_opcode == LIO_READ ? &pread : reinterpret_cast<ActionFunc>(&pwrite);
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org