From e2d7a2559a1c86bd674acb2d468eabbcdda17b89 Mon Sep 17 00:00:00 2001 From: Vesa Karvonen Date: Wed, 23 Jan 2002 16:41:44 +0000 Subject: [PATCH] Minor optimizations [SVN r12460] --- include/boost/preprocessor/arithmetic/add.hpp | 4 ++-- include/boost/preprocessor/arithmetic/div.hpp | 4 ++-- include/boost/preprocessor/arithmetic/mod.hpp | 4 ++-- include/boost/preprocessor/arithmetic/mul.hpp | 4 ++-- include/boost/preprocessor/arithmetic/sub.hpp | 4 ++-- include/boost/preprocessor/list/filter.hpp | 2 +- include/boost/preprocessor/list/fold_left.hpp | 4 ++-- include/boost/preprocessor/list/fold_right.hpp | 2 +- include/boost/preprocessor/list/for_each.hpp | 6 +++--- include/boost/preprocessor/list/rest_n.hpp | 4 ++-- include/boost/preprocessor/list/transform.hpp | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/boost/preprocessor/arithmetic/add.hpp b/include/boost/preprocessor/arithmetic/add.hpp index 275dc67..920cd05 100644 --- a/include/boost/preprocessor/arithmetic/add.hpp +++ b/include/boost/preprocessor/arithmetic/add.hpp @@ -30,8 +30,8 @@ For example, BOOST_PP_ADD(4,3) expands to 7 (a single token). #ifndef DOXYGEN_SHOULD_SKIP_THIS #define BOOST_PP_ADD_D(D,X,Y) BOOST_PP_TUPLE_ELEM(2,0,BOOST_PP_WHILE##D(BOOST_PP_ADD_C,BOOST_PP_ADD_F,(X,Y))) -#define BOOST_PP_ADD_C(D,P) BOOST_PP_TUPLE_ELEM(2,1,P) -#define BOOST_PP_ADD_F(D,P) (BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(2,0,P)),BOOST_PP_DEC(BOOST_PP_TUPLE_ELEM(2,1,P))) +#define BOOST_PP_ADD_C(D,P) BOOST_PP_TUPLE2_ELEM1 P +#define BOOST_PP_ADD_F(D,P) (BOOST_PP_INC(BOOST_PP_TUPLE2_ELEM0 P),BOOST_PP_DEC(BOOST_PP_TUPLE2_ELEM1 P)) #endif //! Obsolete. Use BOOST_PP_ADD(). diff --git a/include/boost/preprocessor/arithmetic/div.hpp b/include/boost/preprocessor/arithmetic/div.hpp index e51658c..f77c8d0 100644 --- a/include/boost/preprocessor/arithmetic/div.hpp +++ b/include/boost/preprocessor/arithmetic/div.hpp @@ -28,8 +28,8 @@ For example, BOOST_PP_DIV(4,3) expands to 1 (a single token). #ifndef DOXYGEN_SHOULD_SKIP_THIS #define BOOST_PP_DIV_D(D,X,Y) BOOST_PP_TUPLE_ELEM(3,0,BOOST_PP_WHILE##D(BOOST_PP_DIV_C,BOOST_PP_DIV_F,(0,X,Y))) -#define BOOST_PP_DIV_C(D,P) BOOST_PP_LESS_EQUAL_D(D,BOOST_PP_TUPLE_ELEM(3,2,P),BOOST_PP_TUPLE_ELEM(3,1,P)) -#define BOOST_PP_DIV_F(D,P) (BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(3,0,P)),BOOST_PP_SUB_D(D,BOOST_PP_TUPLE_ELEM(3,1,P),BOOST_PP_TUPLE_ELEM(3,2,P)),BOOST_PP_TUPLE_ELEM(3,2,P)) +#define BOOST_PP_DIV_C(D,P) BOOST_PP_LESS_EQUAL_D(D,BOOST_PP_TUPLE3_ELEM2 P,BOOST_PP_TUPLE3_ELEM1 P) +#define BOOST_PP_DIV_F(D,P) (BOOST_PP_INC(BOOST_PP_TUPLE3_ELEM0 P),BOOST_PP_SUB_D(D,BOOST_PP_TUPLE3_ELEM1 P,BOOST_PP_TUPLE3_ELEM2 P),BOOST_PP_TUPLE3_ELEM2 P) #endif //! Obsolete. Use BOOST_PP_DIV(). diff --git a/include/boost/preprocessor/arithmetic/mod.hpp b/include/boost/preprocessor/arithmetic/mod.hpp index cc65b13..a345e78 100644 --- a/include/boost/preprocessor/arithmetic/mod.hpp +++ b/include/boost/preprocessor/arithmetic/mod.hpp @@ -27,8 +27,8 @@ For example, BOOST_PP_MOD(4,3) expands to 1 (a single token). #ifndef DOXYGEN_SHOULD_SKIP_THIS #define BOOST_PP_MOD_D(D,X,Y) BOOST_PP_TUPLE_ELEM(2,0,BOOST_PP_WHILE##D(BOOST_PP_MOD_C,BOOST_PP_MOD_F,(X,Y))) -#define BOOST_PP_MOD_C(D,P) BOOST_PP_LESS_EQUAL_D(D,BOOST_PP_TUPLE_ELEM(2,1,P),BOOST_PP_TUPLE_ELEM(2,0,P)) -#define BOOST_PP_MOD_F(D,P) (BOOST_PP_SUB_D(D,BOOST_PP_TUPLE_ELEM(2,0,P),BOOST_PP_TUPLE_ELEM(2,1,P)),BOOST_PP_TUPLE_ELEM(2,1,P)) +#define BOOST_PP_MOD_C(D,P) BOOST_PP_LESS_EQUAL_D(D,BOOST_PP_TUPLE2_ELEM1 P,BOOST_PP_TUPLE2_ELEM0 P) +#define BOOST_PP_MOD_F(D,P) (BOOST_PP_SUB_D(D,BOOST_PP_TUPLE2_ELEM0 P,BOOST_PP_TUPLE2_ELEM1 P),BOOST_PP_TUPLE2_ELEM1 P) #endif //! Obsolete. Use BOOST_PP_MOD(). diff --git a/include/boost/preprocessor/arithmetic/mul.hpp b/include/boost/preprocessor/arithmetic/mul.hpp index 00a43f3..143fa78 100644 --- a/include/boost/preprocessor/arithmetic/mul.hpp +++ b/include/boost/preprocessor/arithmetic/mul.hpp @@ -27,8 +27,8 @@ For example, BOOST_PP_MUL(4,3) expands to 12 (a single token). #ifndef DOXYGEN_SHOULD_SKIP_THIS #define BOOST_PP_MUL_D(D,X,Y) BOOST_PP_TUPLE_ELEM(3,0,BOOST_PP_WHILE##D(BOOST_PP_MUL_C,BOOST_PP_MUL_F,(0,X,Y))) -#define BOOST_PP_MUL_C(D,P) BOOST_PP_TUPLE_ELEM(3,2,P) -#define BOOST_PP_MUL_F(D,P) (BOOST_PP_ADD_D(D,BOOST_PP_TUPLE_ELEM(3,0,P),BOOST_PP_TUPLE_ELEM(3,1,P)),BOOST_PP_TUPLE_ELEM(3,1,P),BOOST_PP_DEC(BOOST_PP_TUPLE_ELEM(3,2,P))) +#define BOOST_PP_MUL_C(D,P) BOOST_PP_TUPLE3_ELEM2 P +#define BOOST_PP_MUL_F(D,P) (BOOST_PP_ADD_D(D,BOOST_PP_TUPLE3_ELEM0 P,BOOST_PP_TUPLE3_ELEM1 P),BOOST_PP_TUPLE3_ELEM1 P,BOOST_PP_DEC(BOOST_PP_TUPLE3_ELEM2 P)) #endif //! Obsolete. Use BOOST_PP_MUL(). diff --git a/include/boost/preprocessor/arithmetic/sub.hpp b/include/boost/preprocessor/arithmetic/sub.hpp index 84b53a7..c9f905f 100644 --- a/include/boost/preprocessor/arithmetic/sub.hpp +++ b/include/boost/preprocessor/arithmetic/sub.hpp @@ -29,8 +29,8 @@ For example, BOOST_PP_SUB(4,3) expands to 1 (a single token). #ifndef DOXYGEN_SHOULD_SKIP_THIS #define BOOST_PP_SUB_D(D,X,Y) BOOST_PP_TUPLE_ELEM(2,0,BOOST_PP_WHILE##D(BOOST_PP_SUB_C,BOOST_PP_SUB_F,(X,Y))) -#define BOOST_PP_SUB_C(D,P) BOOST_PP_TUPLE_ELEM(2,1,P) -#define BOOST_PP_SUB_F(D,P) (BOOST_PP_DEC(BOOST_PP_TUPLE_ELEM(2,0,P)),BOOST_PP_DEC(BOOST_PP_TUPLE_ELEM(2,1,P))) +#define BOOST_PP_SUB_C(D,P) BOOST_PP_TUPLE2_ELEM1 P +#define BOOST_PP_SUB_F(D,P) (BOOST_PP_DEC(BOOST_PP_TUPLE2_ELEM0 P),BOOST_PP_DEC(BOOST_PP_TUPLE2_ELEM1 P)) #endif //! Obsolete. Use BOOST_PP_SUB(X,Y). diff --git a/include/boost/preprocessor/list/filter.hpp b/include/boost/preprocessor/list/filter.hpp index bf24432..2bf2956 100644 --- a/include/boost/preprocessor/list/filter.hpp +++ b/include/boost/preprocessor/list/filter.hpp @@ -33,6 +33,6 @@ expands to a list containing 1 and 3. #ifndef DOXYGEN_SHOULD_SKIP_THIS #define BOOST_PP_LIST_FILTER_D(D,F,P,L) BOOST_PP_TUPLE_ELEM(3,2,BOOST_PP_LIST_FOLD_RIGHT_D(D,BOOST_PP_LIST_FILTER_F,L,(F,P,(_,_,0)))) -#define BOOST_PP_LIST_FILTER_F(D,H,P) (BOOST_PP_TUPLE_ELEM(3,0,P),BOOST_PP_TUPLE_ELEM(3,1,P),BOOST_PP_IF(BOOST_PP_TUPLE_ELEM(3,0,P)(D,BOOST_PP_TUPLE_ELEM(3,1,P),H),BOOST_PP_LIST_CONS,BOOST_PP_TUPLE2_ELEM1)(H,BOOST_PP_TUPLE_ELEM(3,2,P))) +#define BOOST_PP_LIST_FILTER_F(D,H,P) (BOOST_PP_TUPLE_ELEM(3,0,P),BOOST_PP_TUPLE3_ELEM1 P,BOOST_PP_IF(BOOST_PP_TUPLE3_ELEM0 P(D,BOOST_PP_TUPLE3_ELEM1 P,H),BOOST_PP_LIST_CONS,BOOST_PP_TUPLE2_ELEM1)(H,BOOST_PP_TUPLE3_ELEM2 P)) #endif #endif diff --git a/include/boost/preprocessor/list/fold_left.hpp b/include/boost/preprocessor/list/fold_left.hpp index 5c21b5b..f4d1d32 100644 --- a/include/boost/preprocessor/list/fold_left.hpp +++ b/include/boost/preprocessor/list/fold_left.hpp @@ -47,7 +47,7 @@ See BOOST_PP_LIST_FOLD_RIGHT(). #ifndef DOXYGEN_SHOULD_SKIP_THIS #define BOOST_PP_LIST_FOLD_LEFT_D(D,F,P,L) BOOST_PP_TUPLE_ELEM(3,1,BOOST_PP_WHILE##D(BOOST_PP_LIST_FOLD_LEFT_C,BOOST_PP_LIST_FOLD_LEFT_F,(F,P,L))) -#define BOOST_PP_LIST_FOLD_LEFT_C(D,X) BOOST_PP_LIST_IS_CONS(BOOST_PP_TUPLE_ELEM(3,2,X)) -#define BOOST_PP_LIST_FOLD_LEFT_F(D,X) (BOOST_PP_TUPLE_ELEM(3,0,X),BOOST_PP_TUPLE_ELEM(3,0,X)(D,BOOST_PP_TUPLE_ELEM(3,1,X),BOOST_PP_LIST_FIRST(BOOST_PP_TUPLE_ELEM(3,2,X))),BOOST_PP_LIST_REST(BOOST_PP_TUPLE_ELEM(3,2,X))) +#define BOOST_PP_LIST_FOLD_LEFT_C(D,X) BOOST_PP_TUPLE3_ELEM2 BOOST_PP_TUPLE3_ELEM2 X +#define BOOST_PP_LIST_FOLD_LEFT_F(D,X) (BOOST_PP_TUPLE_ELEM(3,0,X),BOOST_PP_TUPLE3_ELEM0 X(D,BOOST_PP_TUPLE3_ELEM1 X,BOOST_PP_TUPLE3_ELEM0 BOOST_PP_TUPLE3_ELEM2 X),BOOST_PP_TUPLE3_ELEM1 BOOST_PP_TUPLE3_ELEM2 X) #endif #endif diff --git a/include/boost/preprocessor/list/fold_right.hpp b/include/boost/preprocessor/list/fold_right.hpp index 885519e..679e65a 100644 --- a/include/boost/preprocessor/list/fold_right.hpp +++ b/include/boost/preprocessor/list/fold_right.hpp @@ -51,6 +51,6 @@ See BOOST_PP_LIST_FOLD_LEFT(). #ifndef DOXYGEN_SHOULD_SKIP_THIS #define BOOST_PP_LIST_FOLD_RIGHT_D(D,F,L,P) BOOST_PP_TUPLE_ELEM(2,1,BOOST_PP_LIST_FOLD_LEFT_D(D,BOOST_PP_LIST_FOLD_RIGHT_F,(F,P),BOOST_PP_LIST_REVERSE_D(D,L))) -#define BOOST_PP_LIST_FOLD_RIGHT_F(D,FR,H) (BOOST_PP_TUPLE_ELEM(2,0,FR),BOOST_PP_TUPLE_ELEM(2,0,FR)(D,H,BOOST_PP_TUPLE_ELEM(2,1,FR))) +#define BOOST_PP_LIST_FOLD_RIGHT_F(D,P,H) (BOOST_PP_TUPLE_ELEM(2,0,P),BOOST_PP_TUPLE_ELEM(2,0,P)(D,H,BOOST_PP_TUPLE2_ELEM1 P)) #endif #endif diff --git a/include/boost/preprocessor/list/for_each.hpp b/include/boost/preprocessor/list/for_each.hpp index c4a44d7..efd985b 100644 --- a/include/boost/preprocessor/list/for_each.hpp +++ b/include/boost/preprocessor/list/for_each.hpp @@ -37,8 +37,8 @@ See BOOST_PP_FOR() for an explanation of the R parameter. #ifndef DOXYGEN_SHOULD_SKIP_THIS #define BOOST_PP_LIST_FOR_EACH_R(R,F,P,L) BOOST_PP_FOR##R((F,P,L,0),BOOST_PP_LIST_FOR_EACH_C,BOOST_PP_LIST_FOR_EACH_F,BOOST_PP_LIST_FOR_EACH_I) -#define BOOST_PP_LIST_FOR_EACH_C(R,FPL) BOOST_PP_LIST_IS_CONS(BOOST_PP_TUPLE_ELEM(4,2,FPL)) -#define BOOST_PP_LIST_FOR_EACH_F(R,FPL) (BOOST_PP_TUPLE_ELEM(4,0,FPL),BOOST_PP_TUPLE_ELEM(4,1,FPL),BOOST_PP_LIST_REST(BOOST_PP_TUPLE_ELEM(4,2,FPL)),BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(4,3,FPL))) -#define BOOST_PP_LIST_FOR_EACH_I(R,FPL) BOOST_PP_TUPLE_ELEM(4,0,FPL)(BOOST_PP_TUPLE_ELEM(4,3,FPL),BOOST_PP_TUPLE_ELEM(4,1,FPL),BOOST_PP_LIST_FIRST(BOOST_PP_TUPLE_ELEM(4,2,FPL))) +#define BOOST_PP_LIST_FOR_EACH_C(R,FPL) BOOST_PP_LIST_IS_CONS(BOOST_PP_TUPLE4_ELEM2 FPL) +#define BOOST_PP_LIST_FOR_EACH_F(R,FPL) (BOOST_PP_TUPLE_ELEM(4,0,FPL),BOOST_PP_TUPLE4_ELEM1 FPL,BOOST_PP_LIST_REST(BOOST_PP_TUPLE4_ELEM2 FPL),BOOST_PP_INC(BOOST_PP_TUPLE4_ELEM3 FPL)) +#define BOOST_PP_LIST_FOR_EACH_I(R,FPL) BOOST_PP_TUPLE4_ELEM0 FPL(BOOST_PP_TUPLE4_ELEM3 FPL,BOOST_PP_TUPLE4_ELEM1 FPL,BOOST_PP_LIST_FIRST(BOOST_PP_TUPLE4_ELEM2 FPL)) #endif #endif diff --git a/include/boost/preprocessor/list/rest_n.hpp b/include/boost/preprocessor/list/rest_n.hpp index b54c2eb..fc7a844 100644 --- a/include/boost/preprocessor/list/rest_n.hpp +++ b/include/boost/preprocessor/list/rest_n.hpp @@ -35,7 +35,7 @@ expands to a list containing * and /. #ifndef DOXYGEN_SHOULD_SKIP_THIS #define BOOST_PP_LIST_REST_N_D(D,N,L) BOOST_PP_TUPLE_ELEM(2,0,BOOST_PP_WHILE##D(BOOST_PP_LIST_REST_N_C,BOOST_PP_LIST_REST_N_F,(L,N))) -#define BOOST_PP_LIST_REST_N_C(D,X) BOOST_PP_TUPLE_ELEM(2,1,X) -#define BOOST_PP_LIST_REST_N_F(D,X) (BOOST_PP_LIST_REST(BOOST_PP_TUPLE_ELEM(2,0,X)),BOOST_PP_DEC(BOOST_PP_TUPLE_ELEM(2,1,X))) +#define BOOST_PP_LIST_REST_N_C(D,X) BOOST_PP_TUPLE2_ELEM1 X +#define BOOST_PP_LIST_REST_N_F(D,X) (BOOST_PP_LIST_REST(BOOST_PP_TUPLE2_ELEM0 X),BOOST_PP_DEC(BOOST_PP_TUPLE2_ELEM1 X)) #endif #endif diff --git a/include/boost/preprocessor/list/transform.hpp b/include/boost/preprocessor/list/transform.hpp index bd8e917..49c23d3 100644 --- a/include/boost/preprocessor/list/transform.hpp +++ b/include/boost/preprocessor/list/transform.hpp @@ -43,6 +43,6 @@ expands to a list containing 3 and 4. #ifndef DOXYGEN_SHOULD_SKIP_THIS #define BOOST_PP_LIST_TRANSFORM_D(D,F,P,L) BOOST_PP_TUPLE_ELEM(3,2,BOOST_PP_LIST_FOLD_RIGHT_D(D,BOOST_PP_LIST_TRANSFORM_F,L,(F,P,(_,_,0)))) -#define BOOST_PP_LIST_TRANSFORM_F(D,H,P) (BOOST_PP_TUPLE_ELEM(3,0,P),BOOST_PP_TUPLE_ELEM(3,1,P),(BOOST_PP_TUPLE_ELEM(3,0,P)(D,BOOST_PP_TUPLE_ELEM(3,1,P),H),BOOST_PP_TUPLE_ELEM(3,2,P),1)) +#define BOOST_PP_LIST_TRANSFORM_F(D,H,P) (BOOST_PP_TUPLE_ELEM(3,0,P),BOOST_PP_TUPLE3_ELEM1 P,(BOOST_PP_TUPLE_ELEM(3,0,P)(D,BOOST_PP_TUPLE3_ELEM1 P,H),BOOST_PP_TUPLE3_ELEM2 P,1)) #endif #endif