summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2020-10-02 14:59:32 +0300
committerTimo Teräs <timo.teras@iki.fi>2020-10-09 16:09:19 +0300
commit2156107afcd1954fd36ab1e55cf73390548e6d07 (patch)
treebdb7a6dc36147308ae8a9145bb0fc8e931edce87 /src
parentf9f8594069fbf8757d350669d0c3a9187bbba4ae (diff)
downloadapk-tools-2156107afcd1954fd36ab1e55cf73390548e6d07.tar.gz
apk-tools-2156107afcd1954fd36ab1e55cf73390548e6d07.tar.bz2
apk-tools-2156107afcd1954fd36ab1e55cf73390548e6d07.tar.xz
apk-tools-2156107afcd1954fd36ab1e55cf73390548e6d07.zip
minor performance improvements on build and code
Diffstat (limited to 'src')
-rw-r--r--src/adb.h1
-rw-r--r--src/apk_adb.c22
-rw-r--r--src/app_adbdump.c2
-rw-r--r--src/app_convdb.c2
-rw-r--r--src/blob.c2
5 files changed, 19 insertions, 10 deletions
diff --git a/src/adb.h b/src/adb.h
index 851aece..e4c2035 100644
--- a/src/adb.h
+++ b/src/adb.h
@@ -113,6 +113,7 @@ struct adb_object_schema {
struct adb_scalar_schema {
uint8_t kind;
+ uint8_t multiline : 1;
apk_blob_t (*tostring)(struct adb*, adb_val_t, char *, size_t);
adb_val_t (*fromstring)(struct adb*, apk_blob_t);
diff --git a/src/apk_adb.c b/src/apk_adb.c
index 3bd5827..2827733 100644
--- a/src/apk_adb.c
+++ b/src/apk_adb.c
@@ -102,6 +102,14 @@ static struct adb_scalar_schema scalar_string = {
.compare = string_compare,
};
+static struct adb_scalar_schema scalar_mstring = {
+ .kind = ADB_KIND_BLOB,
+ .multiline = 1,
+ .tostring = string_tostring,
+ .fromstring = string_fromstring,
+ .compare = string_compare,
+};
+
const struct adb_object_schema schema_string_array = {
.kind = ADB_KIND_ARRAY,
.num_fields = APK_MAX_PKG_TRIGGERS,
@@ -452,13 +460,13 @@ const struct adb_object_schema schema_scripts = {
.kind = ADB_KIND_OBJECT,
.num_fields = ADBI_SCRPT_MAX,
.fields = {
- ADB_FIELD(ADBI_SCRPT_TRIGGER, "trigger", scalar_string),
- ADB_FIELD(ADBI_SCRPT_PREINST, "pre-install", scalar_string),
- ADB_FIELD(ADBI_SCRPT_POSTINST, "post-install", scalar_string),
- ADB_FIELD(ADBI_SCRPT_PREDEINST, "pre-deinstall",scalar_string),
- ADB_FIELD(ADBI_SCRPT_POSTDEINST,"post-deinstall",scalar_string),
- ADB_FIELD(ADBI_SCRPT_PREUPGRADE,"pre-upgrade", scalar_string),
- ADB_FIELD(ADBI_SCRPT_POSTUPGRADE,"post-upgrade",scalar_string),
+ ADB_FIELD(ADBI_SCRPT_TRIGGER, "trigger", scalar_mstring),
+ ADB_FIELD(ADBI_SCRPT_PREINST, "pre-install", scalar_mstring),
+ ADB_FIELD(ADBI_SCRPT_POSTINST, "post-install", scalar_mstring),
+ ADB_FIELD(ADBI_SCRPT_PREDEINST, "pre-deinstall",scalar_mstring),
+ ADB_FIELD(ADBI_SCRPT_POSTDEINST,"post-deinstall",scalar_mstring),
+ ADB_FIELD(ADBI_SCRPT_PREUPGRADE,"pre-upgrade", scalar_mstring),
+ ADB_FIELD(ADBI_SCRPT_POSTUPGRADE,"post-upgrade",scalar_mstring),
},
};
diff --git a/src/app_adbdump.c b/src/app_adbdump.c
index 3914563..6e42a55 100644
--- a/src/app_adbdump.c
+++ b/src/app_adbdump.c
@@ -93,7 +93,7 @@ static void dump_item(struct adb_dump_ctx *ctx, const char *name, const uint8_t
if (!APK_BLOB_IS_NULL(b)) {
fputs(ctx->prefix, stdout);
if (name) fprintf(stdout, "%s: ", name);
- if (b.len >= 60 || apk_blob_chr(b, '\n')) {
+ if (b.len >= 60 || scalar->multiline) {
/* long or multiline */
apk_blob_t l;
fprintf(stdout, "|\n");
diff --git a/src/app_convdb.c b/src/app_convdb.c
index 5b5581e..39a8ad3 100644
--- a/src/app_convdb.c
+++ b/src/app_convdb.c
@@ -199,7 +199,7 @@ static int conv_main(void *pctx, struct apk_database *db, struct apk_string_arra
list_init(&ctx->script_head);
adb_w_init_alloca(&ctx->dbi, ADB_SCHEMA_INSTALLED_DB, 10);
- adb_w_init_alloca(&ctx->dbp, ADB_SCHEMA_PACKAGE, 100);
+ adb_w_init_alloca(&ctx->dbp, ADB_SCHEMA_PACKAGE, 1000);
adb_wo_alloca(&idb, &schema_idb, &ctx->dbi);
adb_wo_alloca(&ctx->pkgs, &schema_package_adb_array, &ctx->dbi);
diff --git a/src/blob.c b/src/blob.c
index 3a20439..aa7ca83 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -192,7 +192,7 @@ apk_blob_t apk_blob_pushed(apk_blob_t buffer, apk_blob_t left)
return APK_BLOB_PTR_LEN(buffer.ptr, left.ptr - buffer.ptr);
}
-static inline uint32_t rotl32(uint32_t x, int8_t r)
+static inline __attribute__((always_inline)) uint32_t rotl32(uint32_t x, int8_t r)
{
return (x << r) | (x >> (32 - r));
}