minor performance improvements on build and code
parent
f9f8594069
commit
2156107afc
|
@ -1,7 +1,7 @@
|
||||||
project(
|
project(
|
||||||
'apk-tools',
|
'apk-tools',
|
||||||
['c'],
|
['c'],
|
||||||
default_options : ['c_std=gnu99'],
|
default_options : ['c_std=gnu99', 'optimization=2'],
|
||||||
version: '3.0.0_pre0',
|
version: '3.0.0_pre0',
|
||||||
meson_version: '>=0.51'
|
meson_version: '>=0.51'
|
||||||
)
|
)
|
||||||
|
|
|
@ -113,6 +113,7 @@ struct adb_object_schema {
|
||||||
|
|
||||||
struct adb_scalar_schema {
|
struct adb_scalar_schema {
|
||||||
uint8_t kind;
|
uint8_t kind;
|
||||||
|
uint8_t multiline : 1;
|
||||||
|
|
||||||
apk_blob_t (*tostring)(struct adb*, adb_val_t, char *, size_t);
|
apk_blob_t (*tostring)(struct adb*, adb_val_t, char *, size_t);
|
||||||
adb_val_t (*fromstring)(struct adb*, apk_blob_t);
|
adb_val_t (*fromstring)(struct adb*, apk_blob_t);
|
||||||
|
|
|
@ -102,6 +102,14 @@ static struct adb_scalar_schema scalar_string = {
|
||||||
.compare = string_compare,
|
.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 = {
|
const struct adb_object_schema schema_string_array = {
|
||||||
.kind = ADB_KIND_ARRAY,
|
.kind = ADB_KIND_ARRAY,
|
||||||
.num_fields = APK_MAX_PKG_TRIGGERS,
|
.num_fields = APK_MAX_PKG_TRIGGERS,
|
||||||
|
@ -452,13 +460,13 @@ const struct adb_object_schema schema_scripts = {
|
||||||
.kind = ADB_KIND_OBJECT,
|
.kind = ADB_KIND_OBJECT,
|
||||||
.num_fields = ADBI_SCRPT_MAX,
|
.num_fields = ADBI_SCRPT_MAX,
|
||||||
.fields = {
|
.fields = {
|
||||||
ADB_FIELD(ADBI_SCRPT_TRIGGER, "trigger", scalar_string),
|
ADB_FIELD(ADBI_SCRPT_TRIGGER, "trigger", scalar_mstring),
|
||||||
ADB_FIELD(ADBI_SCRPT_PREINST, "pre-install", scalar_string),
|
ADB_FIELD(ADBI_SCRPT_PREINST, "pre-install", scalar_mstring),
|
||||||
ADB_FIELD(ADBI_SCRPT_POSTINST, "post-install", scalar_string),
|
ADB_FIELD(ADBI_SCRPT_POSTINST, "post-install", scalar_mstring),
|
||||||
ADB_FIELD(ADBI_SCRPT_PREDEINST, "pre-deinstall",scalar_string),
|
ADB_FIELD(ADBI_SCRPT_PREDEINST, "pre-deinstall",scalar_mstring),
|
||||||
ADB_FIELD(ADBI_SCRPT_POSTDEINST,"post-deinstall",scalar_string),
|
ADB_FIELD(ADBI_SCRPT_POSTDEINST,"post-deinstall",scalar_mstring),
|
||||||
ADB_FIELD(ADBI_SCRPT_PREUPGRADE,"pre-upgrade", scalar_string),
|
ADB_FIELD(ADBI_SCRPT_PREUPGRADE,"pre-upgrade", scalar_mstring),
|
||||||
ADB_FIELD(ADBI_SCRPT_POSTUPGRADE,"post-upgrade",scalar_string),
|
ADB_FIELD(ADBI_SCRPT_POSTUPGRADE,"post-upgrade",scalar_mstring),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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)) {
|
if (!APK_BLOB_IS_NULL(b)) {
|
||||||
fputs(ctx->prefix, stdout);
|
fputs(ctx->prefix, stdout);
|
||||||
if (name) fprintf(stdout, "%s: ", name);
|
if (name) fprintf(stdout, "%s: ", name);
|
||||||
if (b.len >= 60 || apk_blob_chr(b, '\n')) {
|
if (b.len >= 60 || scalar->multiline) {
|
||||||
/* long or multiline */
|
/* long or multiline */
|
||||||
apk_blob_t l;
|
apk_blob_t l;
|
||||||
fprintf(stdout, "|\n");
|
fprintf(stdout, "|\n");
|
||||||
|
|
|
@ -199,7 +199,7 @@ static int conv_main(void *pctx, struct apk_database *db, struct apk_string_arra
|
||||||
list_init(&ctx->script_head);
|
list_init(&ctx->script_head);
|
||||||
|
|
||||||
adb_w_init_alloca(&ctx->dbi, ADB_SCHEMA_INSTALLED_DB, 10);
|
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(&idb, &schema_idb, &ctx->dbi);
|
||||||
adb_wo_alloca(&ctx->pkgs, &schema_package_adb_array, &ctx->dbi);
|
adb_wo_alloca(&ctx->pkgs, &schema_package_adb_array, &ctx->dbi);
|
||||||
|
|
||||||
|
|
|
@ -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);
|
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));
|
return (x << r) | (x >> (32 - r));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue